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

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.