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

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?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2016-10-24 11:24 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (305 votes). Check out past polls.