Im very new to Node-Red and are trying to create a function.
My code looks like this:
let startDate = new Date(2022,8,7,0,0,0,0);
the debug log output is this:
While im expecting it to be 2022-08-07T00:00:00.000Z
Im using Home assistant OS on a Raspberry Pi 4 and the location settings are correct.
Thanks in advance!
new Date(...) function expects a
monthIndex, which starts at
0 for January. So passing in an
8 as you are, actually means September.
As for the hours - the function creates the time in the timezone of the device its running on. If you are passing in
00:00:00 as the time, the fact it results in
22:00:00Z suggests you are in a
Much appreciated for your feedback!
I understand the month index part but if possible could you please provide me an example of how I could achieve creating a starting date of today with the hours 00:00:00?
try without the time ie =new Date(2022, 7, 7)
Do you want midnight local time or midnight UTC?
Your new Date (2022, 8, 7, 0, 0, 0, 0); What you get is a Date instead of a str and your time zone ratio is +2. It is recommended to use moment to solve it. This module is very powerful
It seems that @Draax has lost interest in the question.
Apologize for late response, thanks everyone for the input!
@knolleary 's answer resolved everything
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.