# Text Input Time Picker Returns Incorrect ms From Midnight

**URL:** <https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772>\
**Category:** Dashboard\
**Created:** [24 August 2023 12:23 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772 "2023-08-24T12:23:49Z")\
**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:** [25 August 2023 08:17 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/22 "2023-08-25T08:17:03Z")

</div>

> [@gil27255](#):
>
> Question: why does the text input node (set to time mode) even care what the system time is

That is a very good question, and I hope it will change in the new dashboard being developed. [Text Input Widget timestamp and date input formats · Issue #147 · FlowFuse/node-red-dashboard · GitHub](https://github.com/flowforge/flowforge-nr-dashboard/issues/147)

For the moment though I don't think any breaking changes can be made in the current dashboard. The question is why is your system behaving differently to others. I wonder if it is a peculiarity of PDT.

Is there anyone else out there using PDT?

---

<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:** [25 August 2023 09:02 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/23 "2023-08-25T09:02:46Z")

</div>

Could you configure a default Inject node please, which will inject the timestamp, and feed that straight into a default debug node. Then screenshot what that shows in the debug pane and paste it here. Also tell us what time it is when you do it.

---

<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:** [25 August 2023 09:23 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/24 "2023-08-25T09:23:45Z")

</div>

Also please (if you have not already done so) make sure your pi has the latest packages installed by running  
`sudo apt update && sudo apt full-upgrade`  
and making sure no errors are seen.  
Then restart node-red.

Also do you have any more node-red systems? Can you try on them?

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [25 August 2023 18:44 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/25 "2023-08-25T18:44:52Z")

</div>

I updated the Pi using the command provided above. No errors. I did notice that Node was updated but it did not fix the offset problem from the Text Input control.

I injected a timestamp straight into a debug node. I also added a parallel function node to convert the timestamp into a string date and then back into a timestamp. The results match the current local system time. There is a small offset between the raw input timestamp and the timestamp back-calculated from the converted string date (probably attributable to execution time). I will spin up a Docker container on my Windows computer and and get back to you shortly on the results from that. I appreciate your helping me out with this!

## Debug output plus debug.warn() statements from parallel function node:

```auto
8/25/2023, 11:41:48 AM node: debug 103
msg.payload : number
1692988908165
8/25/2023, 11:41:48 AM node: function 4
function : (warn)
"toLocalString = 8/25/2023, 11:41:48 AM"
8/25/2023, 11:41:48 AM node: function 4
function : (warn)
"back to timestamp = 1692988908000"
8/25/2023, 11:41:48 AM node: function 4
function : (warn)
"timestamp delta = 165 ms"

```

## Parallel function node code that produces above warn statements

```auto
const date = new Date(msg.payload);
const stringDate = date.toLocaleString();
const timeStamp = Date.parse(stringDate);
node.warn(`toLocalString = ${stringDate}`);
node.warn(`back to timestamp = ${timeStamp}`);
node.warn(`timestamp delta = ${msg.payload - timeStamp} ms`)
return;

```

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [25 August 2023 18:53 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/26 "2023-08-25T18:53:03Z")

</div>

I read your flowforge comment and could not agree more!

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [25 August 2023 20:08 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/27 "2023-08-25T20:08:37Z")

</div>

I happened to have a Docker Container on one of my Windows machines (running under WSL2) with an older version of my flows.json file from when I created it (January of this year). The node-red version is 3.0.2 and the dashboard version is 3.2.3. If I add a Text Input node and send the output to a Debug node I get the CORRECT result! I will update to the latest (first the dashboard and then nodered) and see if either change impacts the results.

---

<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:** [25 August 2023 20:45 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/28 "2023-08-25T20:45:11Z")

</div>

What do you define as correct, in terms of what comes out of the text node?

Am I right in thinking that you have to tell the container what the timezone is?

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [25 August 2023 20:55 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/29 "2023-08-25T20:55:18Z")

</div>

By correct I mean the correct number of ms since midnight. In my production flow I have to subtract 8 hrs worth of ms from the output to get the correct result. I do not tell the container what the timezone is as the node, according to documentation, simply takes a time formatted as hh:mm AM/PM, and then returns ms from midnight (e.g. 12:00 AM should output 0 ms, 01:00 AM should output 3.6E6 ms etc.).

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [25 August 2023 20:57 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/30 "2023-08-25T20:57:38Z")

</div>

Which is why I do not think, at least in time mode, the Text Input should have any dependency on system time. It simply calculates the number of ms between hh:mm AM/PM and 00:00 AM.

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [25 August 2023 21:01 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/31 "2023-08-25T21:01:11Z")

</div>

I failed to answer you last question. The container time is the same as my main system time which is the same time as my Pi.

---

<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:** [25 August 2023 21:02 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/33 "2023-08-25T21:02:24Z")

</div>

> [@gil27255](#):
>
> The container time is the same as my main system time

Have you double checked that?

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [25 August 2023 21:03 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/34 "2023-08-25T21:03:39Z")

</div>

Hmmmm......you were correct to point that out. The date command in the container reports UTC time.

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [25 August 2023 21:08 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/35 "2023-08-25T21:08:27Z")

</div>

Which oddly enough is a 7 hour offset. PDT is an 8 hour offset but I think that may be a result of UTC being based on PST (does not account for daylight savings)? Again, I have to correct the output by 8 hrs (not 7) to get the correct ms from midnight from the Text Input controller. Time/dates.....I appreciate they are more complicated than one might think!

---

<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:** [25 August 2023 21:12 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/36 "2023-08-25T21:12:30Z")

</div>

If the timezone is UTC and you enter a time of 00:00 into the node then you should get 0 out.

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [25 August 2023 21:14 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/37 "2023-08-25T21:14:48Z")

</div>

Yes....and I do in the containerized version but not the Pi. The date command in Pi reports PDT. The date command in the container is using UTC.

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [25 August 2023 21:23 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/38 "2023-08-25T21:23:51Z")

</div>

I am thinking.....this is just not worth chasing. I can create a different UI input controller (using a Template node or Text Input without mode set to time) and handle it myself. As you stated, even if there is a bug, the current version of the dashboard is deprecated. So there is no expectation on my part, it will be updated. It is always a good learning process to try and debug something. I've become much more edumacated on how the underlying dashboard code works, but I can work around this rather easily and I don't want to waste your time on what is, a relatively minor issue.

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [25 August 2023 21:32 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/39 "2023-08-25T21:32:12Z")

</div>

I have watched many hours of Nick on YouTube updating the underlying code. I'm not a programmer but get the general concepts and can understand maybe 25%, 50% on a good day. Suffice it to say, I am impressed by all the contributors knowledge and greatly appreciate their efforts! Open source is awesome. As a 54 year old engineer, I have a hard time wrapping my brain around the concept of people giving up so much of their time for free. Kudos to all!

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [25 August 2023 21:46 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/40 "2023-08-25T21:46:18Z")

</div>

With that said, do you and/or the nodered team have a patreon account. I feel compelled to contribute.

---

<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:** [26 August 2023 07:37 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/41 "2023-08-26T07:37:22Z")

</div>

> [@gil27255](#):
>
> Do you and/or the nodered team have a patreon account

Not me.

What happens if you set the timezone of the container to PDT? Does the text input node behave the same as on your pi?

---

<div class="post-metadata">

**Author:** ![gil27255](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gil27255](https://discourse.nodered.org/u/gil27255)\
**Post date:** [26 August 2023 22:06 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/42 "2023-08-26T22:06:41Z")

</div>

I planned on checking that, along with update of dashboard, and then by update of node-red proper. I followed this link on how to change the timezone [Alpine Linux Timezone](https://wiki.alpinelinux.org/wiki/Setting_the_timezone). However, the command `apt add tzdata` returned a `apt: command not found`. One option, I think.....total Docker novice but plan is to migrate off the Pi.....is to alter the image to install tzdata and set to my timezone. Or, maybe it is because I am using a bash terminal rather than the default Alpine terminal (installed that manually). I'm sure I can figure that part out and will post the results as it could be helpful to others going forward. The wife has other chores/plans for me today.....happy wife...happy life!

[Previous page](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772.md?page=1)

[Next page](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772.md?page=3)
