Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Lost in DateTime !

by haukex (Archbishop)
on Jun 13, 2017 at 21:10 UTC ( [id://1192739]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Lost in DateTime !
in thread Lost in DateTime !

There is still a difference though, note that the DateTime object you've built is in the special "floating" time zone, and setting a time zone on it won't adjust the time value:

use warnings; use strict; use DateTime::Format::Strptime; my $strp = DateTime::Format::Strptime->new( on_error=>'croak', pattern => '%Y-%m-%d %H:%M:%S%z'); my @dt = ( $strp->parse_datetime('2017-06-10 21:55:00+02'), DateTime->new(year=>2017,month=>6,day=>10, hour=>21,minute=>55,second=>0), $strp->parse_datetime('2017-06-10 21:55:00+00'), ); for my $i (0..$#dt) { print "$i: ",$dt[$i]->strftime('%Y-%m-%d %H:%M:%S %Z (%z)'),"\n"; $dt[$i]->set_time_zone('Europe/Paris'); print "$i: ",$dt[$i]->strftime('%Y-%m-%d %H:%M:%S %Z (%z)'),"\n"; } __END__ 0: 2017-06-10 21:55:00 +0200 (+0200) 0: 2017-06-10 21:55:00 CEST (+0200) 1: 2017-06-10 21:55:00 floating (+0000) 1: 2017-06-10 21:55:00 CEST (+0200) 2: 2017-06-10 21:55:00 UTC (+0000) 2: 2017-06-10 23:55:00 CEST (+0200)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 21:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found