# Time Picker in ui\_form node sends wrong time in output payload

**URL:** <https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296>\
**Category:** Dashboard\
**Tags:** home-assistant\
**Created:** [26 November 2022 18:08 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296 "2022-11-26T18:08:25Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 November 2022 11:40 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/21 "2022-11-27T11:40:30Z")

</div>

You don't seem to be running the same flow as I am, as both my fields are time and you seem to have a date and a time.

---

<div class="post-metadata">

**Author:** ![Tilerdon](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@Tilerdon](https://discourse.nodered.org/u/Tilerdon)\
**Post date:** [27 November 2022 11:45 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/22 "2022-11-27T11:45:27Z")

</div>

I think that @zenofmud replaced my Start Time field with a date Colin

---

<div class="post-metadata">

**Author:** ![Tilerdon](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@Tilerdon](https://discourse.nodered.org/u/Tilerdon)\
**Post date:** [27 November 2022 11:55 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/23 "2022-11-27T11:55:26Z")

</div>

> [@Colin](#):
>
> I have done what you suggested for @Tilerdon and get
> 
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/6/36573ccaafd8564465f0f23bc271e1292075b0db.png)
> 
> It is 11:30 (UTC) here which is what I put in the start time field.

and I got the same result when I did the same

 ![Screenshot_20221127_113817](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/350a12ef069c60ebf11c3f9cec47a585f76700ef.png)

In our locale we are currently at UTC +00.00 therefore there is no reason to apply an artificial adjustment (DST/BST) to any time. What appears to be happening is that the node is believing that we are still in BST when our clocks will display a time which is one hour ahead of UTC and is applying the adjustment to the time which is output. In your case the node is adding the 5 hours that you are behind GMT

I did update the Dashboard to 3.2.3

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 November 2022 11:58 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/24 "2022-11-27T11:58:22Z")

</div>

I am not running in docker or anything similar, and `Date` in a terminal shows  
`Sun 27 Nov 11:54:41 GMT 2022`  
I see the same thing in multiple browsers on multiple machines so I am out of ideas on why it is wrong here but ok across the pond.

It is nothing to do with the specific form in the example, as it behaves the same with just a form with a time field and nothing else.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 November 2022 12:04 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/25 "2022-11-27T12:04:24Z")

</div>

@zenofmud and @Tilerdon are you running node-red on Windows or Linux? I am on LInux.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 November 2022 14:03 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/26 "2022-11-27T14:03:39Z")

</div>

I'm actually running it on a Mac, but I put it on a Pi and the results are the same. I am using a browser on my Mac to go to the dashboard running on the Pi but that also gives the same correct results.

We need one or two people in other timezones to test it. I know someone I'll contact and have them test it.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [27 November 2022 14:28 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/27 "2022-11-27T14:28:15Z")

</div>

Not the same as being in another timezone but...

With my Raspberry Pi timezone set to London (ie UTC), browser on a PC  
**date** shows `Sun 27 Nov 14:14:12 GMT 2022`  
Put 00:00 in start time, debug shows `1969-12-31T23:00:00.000Z`

**sudo raspi-config** , change timezone to Asia / Colombo,  
Reboot, load NR (same PC, different browser)  
**date** shows `Sun 27 Nov 19:41:12 +0530 2022`  
Put 00:00 in start time, debug shows `1969-12-31T23:00:00.000Z`

ie the form ignores the server timezone and subtracts 1 hour from the input.  
I know, that's not what @zenofmud sees  
It looks like it applies the browser's timezone (0 for me, -5 for zenofmud) and a bit more for luck.

---

<div class="post-metadata">

**Author:** ![Tilerdon](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@Tilerdon](https://discourse.nodered.org/u/Tilerdon)\
**Post date:** [27 November 2022 14:31 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/28 "2022-11-27T14:31:37Z")

</div>

I'm running as an Add-on to Home Assistant, within VirtualBox on Linux Mint. My UI is running on a Windows 11 laptop

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 November 2022 16:04 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/29 "2022-11-27T16:04:43Z")

</div>

I have submitted an issue [Form Time picker gives incorrect time · Issue #787 · node-red/node-red-dashboard · GitHub](https://github.com/node-red/node-red-dashboard/issues/787)

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [27 November 2022 16:13 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/30 "2022-11-27T16:13:30Z")

</div>

Tested here as well. Entered 17:03

NR running on a RPi4, using Chrome browser on my mac, same result if running Chromium browser on the RPi directly

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/f/ef296756d278399fc2fd963141d79a02032a1cb6.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/376c6f605b904e075b79ba0edd7d79351a6e4400.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 November 2022 16:28 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/31 "2022-11-27T16:28:42Z")

</div>

16:03Z is correct for local time UTC+1. So far it only seems to be those on UTC that see the problem.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [27 November 2022 16:42 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/32 "2022-11-27T16:42:14Z")

</div>

Would the fact that DST in the UK started in 1972 have any bearing on the ISO timestamp output for a 1970 date?

From Feb 68 to November 1971 DST was all year round also.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 November 2022 16:45 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/33 "2022-11-27T16:45:56Z")

</div>

Ah, good point, I think we have been here before. I think there is an error in the DST rules that make Jan 1970 appear to be in DST. I can't remember what the fix is.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 November 2022 16:59 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/34 "2022-11-27T16:59:39Z")

</div>

Yes, if I have  
`msg.payload = new Date(0)`  
and feed that into a debug node it shows  
`Thu Jan 01 1970 01:00:00 GMT+0100 (Greenwich Mean Time)`

So it thinks that the timezone is GMT+1

---

<div class="post-metadata">

**Author:** ![Tilerdon](https://avatars.discourse-cdn.com/v4/letter/t/ce73a5/32.png) [@Tilerdon](https://discourse.nodered.org/u/Tilerdon)\
**Post date:** [27 November 2022 17:00 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/35 "2022-11-27T17:00:20Z")

</div>

So isn't the error therefore that the date returned by the Time Picker should be today's date and not 1 Jan 1970?

It now seems I can't make any more replies for 2 hours

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [27 November 2022 17:12 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/37 "2022-11-27T17:12:44Z")

</div>

Moment seems to format the correct time though.  
`$moment("1970-01-01T16:01:00.000Z").format("HH:mm:ss")`  
output  
`17:01:00`

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [27 November 2022 17:19 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/38 "2022-11-27T17:19:10Z")

</div>

Umm, the input is 16:01 and the output is 17:01, so same problem

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [27 November 2022 17:43 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/39 "2022-11-27T17:43:45Z")

</div>

The 16.01 ISO converted to milliseconds is correct. it would probably be better if the output were in milliseconds. Saves any confusion and the developer can convert to what ever zone they wish.  
@Buckskin the 16:01 ISO is in utc not GMT, so is confusing, but correct. it just needs converting to correct time zone. As said above outputing in milliseconds would sort any confusion.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 November 2022 17:55 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/40 "2022-11-27T17:55:32Z")

</div>

> [@E1cid](#):
>
> The 16.01 ISO converted to milliseconds is correct.

Can you explain what you mean by that?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [27 November 2022 18:01 UTC](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296/41 "2022-11-27T18:01:57Z")

</div>

The is timestamp `1970-01-01T16:01:00.000Z` converted to milliseconds is `61260000` which is 17.0166666667 hours. Using `$toMillis()`

[Previous page](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296.md?page=1)

[Next page](https://discourse.nodered.org/t/time-picker-in-ui-form-node-sends-wrong-time-in-output-payload/71296.md?page=3)
