MySQL Forums
Forum List  »  Connector/Node.js

Re: Dates being returned in the wrong timezone
Posted by: Lawrence Marigold
Date: November 26, 2020 03:55AM

Well the dates are generated from json, but as they all look good in workbench and select now() is also off by an hour I don't think that can be the issue?

I have now tried datetime and timestamp columns and the result is the same.

It seems as though the connector is taking a date from the timestamp column and then converting it to a javascript timestamp integer, as if I use unix_timestamp around the column it gives the correct timestamp.

The same thing happens with select now():

await session.sql(`select now()`).execute(function(row){
const date = row[0]; //Gives 11:53
await session.sql('select unix_timestamp(now())').execute(function(row){
const date = new Date(row[0] * 1000); //Gives 10:53 which is the time here in Spain right now

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.