Node datetime and timezones

I’m having trouble understanding the current state of affairs with timezones on a node server.

In PHP data is returned like this, which matches what I see in my database tools. These datetimes were auto-generated by mariadb on record creation using current_timestamp(). The database server and mariadb are set to UTC. When I create the records, the datetime displayed is in fact UTC.

Screen Shot 2021-07-17 at 5.19.36 PM

Everything above is what I’m accustomed to and seems correct.

Now in Node I see the following for the same records:

Screen Shot 2021-07-17 at 5.19.47 PM

@patrick points out in other threads, that node datetime values will comes back in UTC, which is what I’m seeing here, except for the fact, that while it is in UTC format, it has also been converted. But the original time was already in UTC, so it seems to have added 7 hours to UTC???

My understanding of mariadb is from the docs:

If a column uses the DATETIME data type, then any inserted values are stored as-is, so no automatic time zone conversions are performed.

So I don’t think maria is getting in the way here. I’m also assuming the node server defaults to UTC, correct?

My goal throughout my app’s is to store and calculate all datetime values based on UTC and only change to local time when displaying to the end user.

I really thought I had a good handle on datetimes, but clearly more to learn!

What the heck am I missing here?

Community Page
Last updated: