porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.26k stars 262 forks source link

Getting Started video has date-handling bug #697

Closed granthusbands closed 10 months ago

granthusbands commented 10 months ago

In the Getting Started video at the top of https://deno.land/x/postgresjs@v3.3.5 it tries to insert new Date(2020, 0, 1) as a date and gets back a datetime of 2019-12-31T23:00:00.000Z. Is that just a problem in that video, or is it actually a present bug? Either way, the video may need updating.

porsager commented 10 months ago

That's not a bug, but just our good old time zones playing tricks with us ;)

When I recorded this video, I was in Copenhagen during winter which is then +1 UTC. That means when I create new Date(2020, 0, 1) the UTC time will be one hour earlier. As you can see by the Z at the end of the returned timestamp in the video, the returned date is in UTC, so if I was to show it again in the local time it would be correct.