MySQL Forums
Forum List  »  Connector/Node.js

Re: Dates being returned in the wrong timezone
Posted by: Lawrence Marigold
Date: November 27, 2020 08:37AM

OK well I've solved this for my purposes by storing all dates in the DB as timestamps, as that means they are stored as UTC and translated to the servers timezone automatically.

I then set the server's timezone for the session to UTC (so the dates are sent to the connector still in UTC) like so:

await session.sql('SET time_zone = '+00:00'').execute();

That way the dates that node receives are in UTC and it automatically converts them to the correct timezone for the server.

Any other clients are unaffected and therefore I can use workbench with the timestamps shown in the correct timezone.

Thanks for all your help.

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.