develooper Front page | perl.beginners | Postings from April 2002

Re: Backing up two days from localtime

Thread Previous
From:
Jeff 'japhy' Pinyan
Date:
April 25, 2002 23:06
Subject:
Re: Backing up two days from localtime
Message ID:
Pine.GSO.4.21.0204260204040.18750-100000@crusoe.crusoe.net
On Apr 26, Tara Calishain said:

>I need to back up two days from localtime and I can't figure out how to do
>it. Currently I'm doing this just so I can work out the rest of the program:
>
>($day, $month, $year) = (localtime) [3,4,5]; #getting your local time 

The generic (read: potentially unsafe) way is to fix the problem right
there:

  ($day, $month, $year) = (localtime(time - 86400*2))[3,4,5];

The only place to worry about this is during the switch to/from Daylight
Savings Time, at 2:00 am, twice a year.

-- 
Jeff "japhy" Pinyan      japhy@pobox.com      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.
[  I'm looking for programming work.  If you like my work, let me know.  ]


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About