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.


🦛


In reply to Re: Baffled by DateTime by hippo
in thread Baffled by DateTime by BernieC

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.