in reply to Baffled by DateTime
I've tried "DateTime->now(timezone=>"EST5EDT") and it blows up with errors.
As ever, those errors (which you've decided to omit from your post for some unknown reason) hold the clue:
$ perl -MDateTime -e 'print DateTime->now(timezone=>"EST5EDT")->hour' Found extra parameters passed to _check_named_from_epoch_params: [time +zone] Trace begun at (eval 241) line 155 DateTime::_check_named_from_epoch_params('epoch', 1680269935, 'timezon +e', 'EST5EDT') called at /usr/local/lib64/perl5/DateTime.pm line 493 DateTime::from_epoch('DateTime', 'epoch', 1680269935, 'timezone', 'EST +5EDT') called at /usr/local/lib64/perl5/DateTime.pm line 545 DateTime::now('DateTime', 'timezone', 'EST5EDT') called at -e line 1
Found extra parameters passed to _check_named_from_epoch_params: [timezone] tells us that it isn't expecting timezone there, so you can go back to the doc and discover that what you actually need is time_zone instead. See the difference:
$ perl -MDateTime -e 'print DateTime->now(time_zone=>"EST5EDT")->hour' 9
Always include the full text of the error message in your post. Even if you don't understand it, someone else probably does.
🦛
|
|---|