Time Picker in ui_form node sends wrong time in output payload

This is my first post on this forum though I've been using Node-RED for just over a year now. I hope I get it right

I have a form element with type "Time"

On focus the dropdown displays the current time as the default correctly but on submission the hour has been reduced by 1 hour. This occurs both using Microsoft Edge and the AVG Secure Browser. All other times in my system display correctly

I am running the Node-RED integration version 13.5.3 under Home Assistant Home Assistant 2022.11.4
Supervisor 2022.11.2
Operating System 9.3
Frontend 20221108.0 - latest

I produced a simple flow to exemplify the problem

Screenshot 2022-11-26 175336

[{"id":"2fbaad6f2b46c829","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"5a3f7a04aed08be7","type":"debug","z":"2fbaad6f2b46c829","name":"debug 40","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":440,"y":160,"wires":[]},{"id":"a5cf4986139c19c7","type":"ui_form","z":"2fbaad6f2b46c829","name":"Switches","label":"<font color= {{msg.color}} > {{msg.payload}}</font>","group":"343f7063521c327e","order":10,"width":0,"height":0,"options":[{"label":"Start Time","value":"Start","type":"time","required":true,"rows":null},{"label":"End Time","value":"End","type":"time","required":false,"rows":null},{"label":"State","value":"State","type":"switch","required":true,"rows":null},{"label":"All Days","value":"All","type":"checkbox","required":false,"rows":null},{"label":"Sun","value":"Sun","type":"checkbox","required":false,"rows":null},{"label":"Mon","value":"Mon","type":"checkbox","required":false,"rows":null},{"label":"Tue","value":"Tue","type":"checkbox","required":false,"rows":null},{"label":"Wed","value":"Wed","type":"checkbox","required":false,"rows":null},{"label":"Thu","value":"Thu","type":"checkbox","required":false,"rows":null},{"label":"Fri","value":"Fri","type":"checkbox","required":false,"rows":null},{"label":"Sat","value":"Sat","type":"checkbox","required":false,"rows":null}],"formValue":{"Start":"","End":"","State":false,"All":false,"Sun":false,"Mon":false,"Tue":false,"Wed":false,"Thu":false,"Fri":false,"Sat":false},"payload":"","submit":"submit","cancel":"cancel","topic":"topic","topicType":"msg","splitLayout":true,"className":"","x":300,"y":160,"wires":[["5a3f7a04aed08be7"]]},{"id":"a6cb819ce376fc58","type":"inject","z":"2fbaad6f2b46c829","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":160,"wires":[["a5cf4986139c19c7"]]},{"id":"343f7063521c327e","type":"ui_group","name":"test","tab":"62712bbf.888b94","order":3,"disp":true,"width":"6","collapse":false,"className":""},{"id":"62712bbf.888b94","type":"ui_tab","name":"test","icon":"dashboard","disabled":false,"hidden":false}]

Unfortunately as a new user I'm unable to post the screenshots of the Input form and data and the object shown by debug

@Tilerdon welcome to the forum.

What timezone are you in?
Please run your flow and then expand the output of the debug node and copy/paste it to a reply.

There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

It wouldn't let me do it in the original post.

I'm literally 3 miles from the Greenwich Meridian

Can you click on the hamburger menu (top right) in the editor and select the 'Manage palette'go to the 'Palette Manager' then search for 'dashboard' and tell me what version you are running.

Version 3.2.0

latest version is 3.2.3 but don't worry about that for the moment. My concern is why the Start time has a date of 1970... I'm going to look into that a bit.

I only put the date input element in there to try and correct that but it had no effect. The dropdown Calendar in the Date input did correctly highlight today

To put a few things into perspective - I'm 74 years old and until August 2021 I had never heard of Home Assistant or Node-RED, and knew nothing about the use of JavaScript, Linux, VirtualBox, HTML, CSS and many of the other components used in the Home Automation Project.

I have a programming background but only in the conventional languages used in the latter half of the last century. I hadn't done anything serious with a computer since 2004. But this is my main Node-RED Dashboard

It monitors and controls my whole house heating system along with some lights, and a few other devices. Apart from the Tuya, Tapo, and Meross devices there are at present 3 home built devices, One a temperature sensor, one a set of 3 thermometers that display the water temperatures at 3 levels in a hot water storage cylinder and finally the main boiler programmer which itself is over 1000 lines of C++

But in truth I don't count myself as competent in any of these things - although I'm not really sure how to use the debug sidebar to any more effect than reading the debug output itself . Even though it works and I saved over $1200 in Heating Oil during the last year.

3 Likes

I'm not that far behind you :smile:, that said you done a lot! That dashboard looks great!

All dates and times are stored (if I have this right) as a Unix timestamp. The reason the date shows up with a 1970...date is that it is translated into the amount of milliseconds offset from the UNIX base time which is 1970-01-01T00:00:00.000Z.

If I'm not mistaken, your day light savings time started a couple weeks ago. So I think what you are seeing is the correct time just offsetted by DST.

You always want to store data and time as a UNIX timestamp and then correct the offset based on your time zone. For instance, If I enter 17:00 I get a value in the debug of 1970-01-01T10:09:00.000Z because I'm in the US.

In the UK DST ended recently so we are now on UTC. I am seeing the same symptom as @Tilerdon. It is certainly appears to be wrong. What time zone are you in @zenofmud?

We are now in GMT , Our summertime is the aberration from normal time so no adjustment should be necessary at this time of year

I have checked with a Form with only a Time field and it shows the same issue, so it is nothing to do with the other stuff in the form.
I am using NR 3.0.2 and dashboard 3.2.3, nodejs 16.18.1

I'm on Eastern Standard Time (GMT-5)

That is a swish (nice) dashboard.

Top marks for it.

Thank you, that is very kind of you to say so

Doesn't that mean you should get 22:00Z when you enter 17:00?

I've gone back to the Form that I am actually working on rather than just using the test flow that I started with in this discussion. As I said earlier, I did actually only include the Date element forthe purpose of analysing this problem. I do however believe it shows that the REAL time and date values are available to the Form node but it corrupts them on output.

This shows the Calendar dropdown Highlighting todays date - 27 Novemeber 2022 - which I select

The Time Picker dropdown also shows the current time (check this with Windows Time/Date in Taskbar)

Date is held correctly in the msg.payload object but the Start time is corrupted and I can see no way that I can influence the output of the Form node to correct it other than by cocing in my own calculations for the date ranges of when we are on UTC or DST.

It is working correctly for me. Here is what I pick:
Screen Shot 2022-11-27 at 5.45.48 AM

and here is the debug - notice the date portion of the timestamp is 5 hours off as it should be.
Screen Shot 2022-11-27 at 5.49.53 AM

Please update the ui-form node to the latest v3.2.3 If you notice on my form it shows the AM/PM but on yours it doesn't
Screen Shot 2022-11-27 at 5.52.39 AM

I think maybe you pasted the wrong image for the debug.

I am running on v3.2.3

I believe whether it shows am/pm or not is down to the locale settings. On Android,for me, it shows a clock.

Yup!, grabbed the wrong image - fixed, thanks

@Tilerdon what do you see in the debug if you edit the inject node and set msg.topic to display a timestamp, do a deploy, press the inject then in the dashboard enter the current time. Look at the debug and click on the value in the topic and you will see it rotate thru various representations of the time. When it gets to the 'topic: 2022-11-27T11:00:44.897Z' format, does the time offset (which I hi-lighted in red' match the time offset at the top of the debug message 11/27/2022, 6:01:01 AMnode: debug 40. Since I GMT-5 if I add 5 to the time hour (6) it is 11 as it should be.

Also have you tried this in Fierefos and or Chrome and from another computer on our network?

One other thing, when you click on the msg.topic time, click till you see the time shown with the (UTC-5) format. What is it showing?

I have done what you suggested for @Tilerdon and get

image

It is 11:30 (UTC) here which is what I put in the start time field.