Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: What's "Better" DateTime or localtime?

by runrig (Abbot)
on Jul 17, 2013 at 21:44 UTC ( #1044913=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use Time::Piece qw(localtime);
    use Time::Seconds qw(ONE_DAY);
    ...
    print "Today: ", $t->ymd(),"\n";
    print "Yesterday: ", $yesterday->ymd(),"\n";
    print "Tomorrow: ", $tomorrow->ymd(),"\n";
    
  2. or download this
    my $t = localtime->strptime(localtime->ymd(), '%Y-%m-%d');
    my $yesterday = $t - ( 0.5 * ONE_DAY() );
    ...
    print "Today: ", $t->ymd(),"\n";
    print "Yesterday: ", $yesterday->ymd(),"\n";
    print "Tomorrow: ", $tomorrow->ymd(),"\n";
    
  3. or download this
    my $t = localtime->strptime('2013-03-11', '%Y-%m-%d');
    my $yesterday = $t - ONE_DAY();
    ...
    Today: 2013-03-11
    Yesterday: 2013-03-09
    Tomorrow: 2013-03-12
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2014-07-22 22:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (130 votes), past polls