I've tried "DateTime->now(timezone=>"EST5EDT") and it blows up with errors.
Probably because the argument is called time_zone, not timezone?
$ perl -wMstrict -MDateTime -le 'print DateTime->now->strftime("%Y-%m- +%d %H:%M:%S %z")' 2023-03-31 13:08:16 +0000 $ perl -wMstrict -MDateTime -le 'print DateTime->now(time_zone=>"local +")->strftime("%Y-%m-%d %H:%M:%S %z")' 2023-03-31 15:08:23 +0200 $ perl -wMstrict -MDateTime -le 'print DateTime->now(time_zone=>"EST5E +DT")->strftime("%Y-%m-%d %H:%M:%S %z")' 2023-03-31 09:08:29 -0400 $ perl -wMstrict -MDateTime -le 'print DateTime->now(time_zone=>"Ameri +ca/New_York")->strftime("%Y-%m-%d %H:%M:%S %z")' 2023-03-31 09:13:15 -0400 $ perl -wMstrict -MDateTime -le 'print DateTime->now(timezone=>"EST5ED +T")->strftime("%Y-%m-%d %H:%M:%S %z")' Found extra parameters passed to _check_named_from_epoch_params: [time +zone]
Update: In regards to local, see Determining the Local Time Zone Can Be Slow. Also, I would recommend to stay away from ambiguous time zone names like CST ("Central Standard Time", "China Standard Time", "Cuba Standard Time", ...) - correspondingly, I updated my examples above to use %z instead of %Z. Update 2: Added the America/New_York example as an alternative to EST5EDT, as noted on Wikipedia.
In reply to Re: Baffled by DateTime
by haukex
in thread Baffled by DateTime
by BernieC
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |