Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Just another Perl shrine
 
PerlMonks  

Re: How do i find yesterday's date

by laurentschneider (Initiate)
on Jun 09, 2004 at 06:47 UTC ( [id://362681]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to How do i find yesterday's date

To bypass the dst problem, you can do "this morning at 0:00 minus twelve hours".
@T=localtime(time-time%86400-43200); printf("%02d/%02d/%02d",$T[4]+1,$T[3],($T[5]+1900));
This works only for dates < 19-JAN-2038 (which is 2 ^ 31 in perl). Regards Laurent Schneider

Replies are listed 'Best First'.
Re: Answer: How do i find yesterday's date
by haoess (Curate) on Jun 09, 2004 at 07:15 UTC

    This question has been answered in perlfaq4 using Date::Calc and working with use strict.

    »Jan 19 2038« is not perl's problem. It depends on your libc and/or your 32/64 bit processor. With these problems your code only works until 2**31 - 1 (at least at my machine).

    -- Frank

Re: Answer: How do i find yesterday's date
by pbeckingham (Parson) on Jun 09, 2004 at 11:16 UTC

    As was pointed out to me some time ago, be careful with assumptions about length of day. There are, I think up to three opportunities per year for there to not be 24 hours of 60 minutes of 60 seconds in a day.

Re: Answer: How do i find yesterday's date
by dse (Novice) on Jun 09, 2004 at 12:03 UTC
    I'd like to point out that this solution will also not work when the timezone is 12 or more hours on either side of GMT (I believe there are some that are off by 13 hours). It's probably best to stick with Date::Calc.
    $ date; TZ=GMT0 date Wed Jun 9 12:01:15 EDT 2004 Wed Jun 9 16:01:15 GMT 2004 $ TZ=GMT-12 perl foo.pl 06/09/2004 $ TZ=GMT+12 perl foo.pl 06/08/2004 $ TZ=GMT-13 perl foo.pl 06/09/2004 $ TZ=GMT+13 perl foo.pl 06/07/2004

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://362681]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.