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 11: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 15: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 16: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