Easiest way to convert from GMT into Local

Hello -

I am taking timestamps and inserting them into SQLite which come from energy readings off my solar panel.

The API I am using is from WattVision and they are reporting the times GMT.

My goal is to write a function, or better yet, just use some default nodes, to convert the time after the HTTP call, into PST time, before writing it into the DB.

Does anyone have a simple recommendation or couple lines of code they can share that would achieve this using the function node?


without seeing an example of the GMT time you have it is difficult to suggest any code.

There are several nodes that help with time conversion on flows.nodered.org as well as tonnes of results if you google javascript converting from GMT

If you do want to convert to local I’d suggest doing it without and daylight savings to avoid double values or no values on the time zone change

Really, you should always store the data as UTC/GMT/Zulu time as this avoids multi-conversion issues as well as summer time issues.

Convert on display where required, otherwise, always storing as UTC lets you do date/time calculations a lot easier and more consistently.

Thanks. Sounds like I should just leave it in the DB as is, then when I present on a dashboard or do analytics, I’ll figure it out.

1 Like