A month ago I set up a new server with Ubuntu 22 for a client, replacing an old one that had Ubuntu 18, which I upgraded to Ubuntu 20. The server has about tqo dozen scripts that I've developed and supported for the last six years. He's very happy with the setup.

However, I've been having some challenges with time zones with the new server. I did specify the Eastern (America/Toronto) time zone during installation, and this appeared to work (when logged in as a regular user), until I noticed that cron jobs were running at UTC time. Eventually I figured out I had to set the system time zone (see this post on Mastodon) using timedatectl set-timezone America/Toronto. There's still one script that was mis-behaving, though. The log file showed that the time period is was fetching transactions was correct ..

2024/06/03 07:02:02 INFO : Starting date is 2024-05-27 00:00:00 EDT 2024/06/03 07:02:02 INFO : Ending date is 2024-05-28 00:00:00 EDT
But the epoch values that were being used
..created[gte]=1716782400&created[lt]=1716868800
were UTC. ?!??!?

Naturally, I went back to the documentation at DateTime and saw that for the epoch method, it returns ".. the UTC epoch value for the datetime object." This is confusing to me, since I'm expecting an epoch value in the selected time zone. Those epoch values are four hours later than what I want, and this is messing things up for my client -- this code has worked fine for ~6 years, but is now broken.

I'm not asking for a fix (I know what I need to do), I'm just asking whether some concept was adjusted somewhere. Thanks.

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.


In reply to SOLVED: DateTime's epoch method returns UTC value? by talexb

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.