On Feb 8, John W. Krahn said:

>Mayank wrote:
>> Is there a module/or some function to do calculations on date e.g. if
>> today is 1st March, and i want the date for previous day (i.e. 28th or
>> 29th Feb)
>
>$ perl -le'
>print scalar localtime;
>print scalar localtime( time - 24 * 60 * 60 );
>'
>Fri Feb  8 04:36:56 2002
>Thu Feb  7 04:36:56 2002

That will break during daylight savings time adjustment... it's safer to
get the time for noon, and THEN subtract 86400 from it, or to subtract 60
* 60 * ($hours + 2) where $hours is the current hour of the day.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to