Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Yesterday Date

by mifflin (Curate)
on Feb 04, 2008 at 20:18 UTC ( #666086=note: print w/replies, xml ) Need Help??


in reply to Yesterday Date

Possible pure Perl solution...
my $wday = (localtime)[6]; my $offset = $wday == 1 ? 3 : ($wday == 0 ? 2 : 1); my @date = localtime(time - 86400*$offset); printf "%s-%s-%s\n", 1900+$date[5], 1+$date[4], $date[3];
Doesn't take into account holidays, just weekends.

Replies are listed 'Best First'.
Re^2: Yesterday Date
by vlademonkey (Pilgrim) on Feb 04, 2008 at 20:56 UTC
    Also doesn't take into account Daylight_saving, where a day can be 25 hours long. As others stated, using a well-tested CPAN library is your best bet with date manipulation.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://666086]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2023-02-05 13:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (31 votes). Check out past polls.

    Notices?