Getting date in nodered

Hey.
I've tried getting date in javascript using the "new Date()" It works but I only want hours, minutes, secs, day, month and year. I don't want it to tell me which timezone I'm in. Is there any way to do that in node red?

https://flows.nodered.org/node/node-red-contrib-simpletime or https://flows.nodered.org/node/node-red-contrib-moment perhaps?

Or as you are already using javascript in a function node just use the javascript Date
to do it
https://www.w3schools.com/jsref/jsref_obj_date.asp

1 Like

The JS Date object is in UTC by definition. You cannot have a date/time without a timezone of some sort since that wouldn't make sense. All time is relative. Work in UTC by default, convert to local time only for user display or user input.

In addition to the other nodes mentioned, the inject node has a timestamp option and the change node can use JSONata which can also output a date/time.

1 Like