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

Re^2: Compare two dates

by AnomalousMonk (Archbishop)
on Jul 22, 2019 at 20:24 UTC ( [id://11103165]=note: print w/replies, xml ) Need Help??


in reply to Re: Compare two dates
in thread Compare two dates

your print statements are equal.

There still seems to be a problem with the print statement because:

c:\@Work\Perl\monks>perl -wMstrict -le "use feature 'say'; use DateTime; my $d1 = DateTime->new( year => 1999, month => 8, day => 1, time_zone => 'America/Chicago', ); my $d2 = DateTime->new( year => 2019, month => 6, day => 8, time_zone => 'America/Chicago', ); say DateTime->compare( $d1, $d2 ) ? $d1->ymd .' is greater than ' . $d2->ymd : $d2->ymd .' is greater or equal to ' . $d1->ymd; " 1999-08-01 is greater than 2019-06-08
Maybe something like:
c:\@Work\Perl\monks>perl -wMstrict -le "use feature 'say'; use DateTime; my $d1 = DateTime->new( year => 1999, month => 8, day => 1, time_zone => 'America/Chicago', ); my $d2 = DateTime->new( year => 2019, month => 6, day => 8, time_zone => 'America/Chicago', ); ;; my $comparison = DateTime->compare($d1, $d2); $comparison = $comparison > 0 ? 'greater than' : $comparison < 0 ? 'less than' : 'equal to'; ;; say sprintf '%s is %s %s', $d1->ymd, $comparison, $d2->ymd; " 1999-08-01 is less than 2019-06-08


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-24 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found