in reply to Date operations

You should really think about using Date::Calc and/or Date::Manip. These might be overkill for this particular task but are lifesavers if you have to do anything else with dates.

You could also look at Time::Local which does the opposite of localtime

another (inelegant) solution would be to take the time() and add the seconds to get to the proper date from today

localtime(time() + (60 * 60 * 24 * 4) + (60 * 60 * 24 * $days)) # add +4 days localtime(time() - (60 * 60 * 24 * 7) + (60 * 60 * 24 * $days)) # subt +ract 1 week


grep
Just me, the boy and these two monks, no questions asked.

Replies are listed 'Best First'.
Re: Re: Date operations
by kidd (Curate) on Aug 11, 2002 at 23:16 UTC
    You should really think about using Date::Calc and/or Date::Manip. These might be overkill for this particular task but are lifesavers if you have to do anything else with dates.

    The reason I liked the current way Im making the operations is that I dont have to get or install any modules...wich are a pain in the a** to configure in my hosting service...

      pain in the a** to configure in my hosting service...

      One (including myself) might argue that recreating any portion of Date::Calc or Date::Manip is a pain in the a$$, since it is already correctly done for you.

      I think you will agree with me the first time you forget one of the rules for leapyears or your client says he/she wants 30 days to not including weekends ;-)

      You most likely have seen this already but, if it helps tachyon has a tutorial on this.



      grep
      Just me, the boy and these two monks, no questions asked.

      from the Perl CGI Programming FAQ:

      (if you don't) have access to install these modules with the other Perl library files, you can still use it by placing the module in a convenient place and adding the following to your script: BEGIN { unshift (@INC, "/your/dir/favorite/place"); }