# 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:** 17\
**Page:** 3

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 August 2023 23:33 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/43 "2023-08-26T23:33:26Z")

</div>

> [@gil27255](#):
>
> 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`

You are getting your alpines mixed up with your Debians. It's `apk` not `apt` (re-read that linked doc 😂)

---

<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:** [29 August 2023 02:05 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/44 "2023-08-29T02:05:38Z")

</div>

I tried `apk add tzdata` but received the following error. I'm less fluent with Linux than I am JS (need to have a cheat sheet nearby although I love the command line). I am a complete novice with Docker containers. I spent a couple of days and after much trial and tribulation, was able to create a node-red container (with my flows.json file imported) talking to a mqtt container that I could access from an external computer (one of those woo-hoo moments where you want to share your accomplishment with someone but......the wife had absolute zero appreciation for 😰) That said, I am sure, with the help of Google, I will figure it out. Mondays, work-wise, are well.......Mondays. So it will probably take me a couple of days before I can get back to this and post the results. I appreciate the suggestion!

```auto
ERROR: Unable to lock database: Permission denied
ERROR: Failed to open apk database: Pefmission denied

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [29 August 2023 05:56 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/45 "2023-08-29T05:56:34Z")

</div>

> [@gil27255](#):
>
> `Unable to lock database: Permission denied`

That particular error and that particular command means you need to do it with `sudo`

---

<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:** [29 August 2023 06:12 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/46 "2023-08-29T06:12:01Z")

</div>

> [@gil27255](#):
>
> I am a complete novice with Docker containers

Why are you using docker then?

---

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

</div>

I am not. I am running my production system on a pi. You asked me if I had any other node-red systems to test on. I was messing around with Docker containers as learning exercise and because I'd like to eventually move my system off a pi to something more powerful. But I have not done that yet precisely because I do not have sufficient experience. Baby steps:)

---

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

</div>

That particular error and that particular command means you need to do it with `sudo`

Yes....that was my first thought but it returns:

```auto
sudo: command not found

```

Anyhow, I can figure that part out, not a big deal. It just is not going to happen on a Monday.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [29 August 2023 07:46 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/49 "2023-08-29T07:46:28Z")

</div>

> [@gil27255](#):
>
> Yes....that was my first thought but it returns:
> 
> ```auto
> sudo: command not found
> 
> ```

That is another nod to what @colin said :-

> [@Colin](#):
>
> Why are you using docker then

Apline images don't ship with `sudo`: [linux - Use sudo inside Dockerfile (Alpine) - Stack Overflow](https://stackoverflow.com/questions/49225976/use-sudo-inside-dockerfile-alpine)

---

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

</div>

I understand my ignorance with Docker images complicates the main issue. That was not my intent and why I am NOT seeking help with that. I am confident I can figure it out. In terms of why Docker: I was playing around with it to expand my knowledge and because there are other containers, that require Linux, I would like to run on an Intel Nuc I have on hand. My first Docker container attempt (as a learning experience) was to get node-red and MQTT up and running. So when Colin asked if I had another system running node-red, I said to myself, self....yes I do in the form of a Docker container. Could I install node-red directly onto a Windows 10 or 11 machine? Yes, but that will take as long as it will to figure out how to change the time zone in a Docker container (it can't be that hard).

---

<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:** [30 August 2023 03:45 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/51 "2023-08-30T03:45:54Z")

</div>

# RESULTS

## Executive Summary

Upgrading the node-red dashboard from 3.2.3 to 3.5 causes the problem. Specifically, the number of ms since midnight for a Text Input set to Time mode is offset by 8 hours worth of ms when your time zone is set to PDT (US - Pacific Daylight Time)

## Detail-1 (Dashboard Version 3.2.3 Works As Expected)

I was able to change the timezone in the node-red docker container. I simply had to attach a terminal as root before I could install tzdata (the default user is "node-red"). As mentioned above sudo is also not installed by the image. My simple test flow (included below, consists of - Text Input node to Function node to Debug node) produces the CORRECT result (i.e., the correct number of ms since midnight local time) using node-red dashboard v 3.2.3. The following is the output for a Text Input node set to Time mode with an input of 02:00 AM:

## Results for Detail-1

```auto
8/29/2023, 7:52:08 PMnode: Calc Time
function : (warn)
"mSec = 7200000"
8/29/2023, 7:52:08 PMnode: Calc Time
function : (warn)
"02:00"
8/29/2023, 7:52:09 PMnode: debug 30
msg.payload : string[5]
"02:00"

```

## Detail-2 (Text Input Node Produces Incorrect Result After Update to Dashboard t v3.5)

I then upgraded the dashboard to 3.5 (via Manage Palette), restarted the container, and checked via the `date` command my current time zone was still PDT (which was true). The following is the output from the same test flow with the same input of 2:00 AM. It returns 10:00 AM and is therefore offset by positive 8 hours:

```auto
8/29/2023, 8:10:23 PMnode: Calc Time
function : (warn)
"mSec = 36000000"
8/29/2023, 8:10:23 PMnode: Calc Time
function : (warn)
"10:00"
8/29/2023, 8:10:23 PMnode: debug 30
msg.payload : string[5]
"10:00"

```

## Conclusion

I believe this proves there is a bug with the update as it is reproducible on both a Pi and a Docker container running under WSL2 on a Windows machine. I understand the dashboard code is deprecated. Therefore, I will adjust my flow to avoid using the Text Input node set to Time mode. I greatly appreciate everyone's input and I am not just saying that. Donating your free time to help us "technology challenged users" is very generous!!!

## Test Flow Used for Both Cases (Detail-1 and Detail-2)

```auto
[
    {
        "id": "a6847b2886a8226d",
        "type": "ui_text_input",
        "z": "bfc13c72.c79e1",
        "name": "",
        "label": "",
        "tooltip": "",
        "group": "e42c6421.b8b248",
        "order": 7,
        "width": 0,
        "height": 0,
        "passthru": false,
        "mode": "time",
        "delay": "0",
        "topic": "topic",
        "sendOnBlur": false,
        "className": "",
        "topicType": "msg",
        "x": 160,
        "y": 1620,
        "wires": [
            [
                "ce34a537ceac0b5e"
            ]
        ]
    },
    {
        "id": "ce34a537ceac0b5e",
        "type": "function",
        "z": "bfc13c72.c79e1",
        "name": "Calc Time",
        "func": "const mSec = msg.payload;\nnode.warn(`mSec = ${mSec}`);\nmsg.payload = parseInt(mSec / 3.6e6).toString().padStart(2, '0') + ':' + parseInt((mSec % 3.6e6) / 6e4).toString().padStart(2, '0');\nnode.warn(msg.payload);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 340,
        "y": 1620,
        "wires": [
            [
                "5c9c0ad24b8d8516"
            ]
        ]
    },
    {
        "id": "5c9c0ad24b8d8516",
        "type": "debug",
        "z": "bfc13c72.c79e1",
        "name": "debug 30",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 520,
        "y": 1620,
        "wires": []
    },
    {
        "id": "e42c6421.b8b248",
        "type": "ui_group",
        "name": "Lights",
        "tab": "a7366c5.92e209",
        "order": 1,
        "disp": true,
        "width": "8",
        "collapse": true,
        "className": ""
    },
    {
        "id": "a7366c5.92e209",
        "type": "ui_tab",
        "name": "Main 1",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [30 August 2023 08:11 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/52 "2023-08-30T08:11:28Z")

</div>

Excellent digging and diagnosis. While the dashboard is not deprecated it is definitely on life support, but bug fixes (or regressions) like this can certainly be undone. I will try to find time to do that in the next few days.

---

<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:** [31 August 2023 02:48 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/53 "2023-08-31T02:48:13Z")

</div>

Thank you @dceejay! I figure if people such as yourself are willing to dedicate so much of your time the least I can do as a user asking a question is to be willing put forth effort myself. Also, I tend to learn more when I struggle to solve a problem so it is a worthwhile endeavor. I really appreciate your dashboard. Great work!

---

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

</div>

Do you know the cause of the problem Dave?

**[Edit]** In particular what it is that is special about 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:** [5 September 2023 14:23 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/55 "2023-09-05T14:23:47Z")

</div>

How is it with the new version of the dashboard, 3.6.0?

---

<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:** [16 September 2023 05:17 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/56 "2023-09-16T05:17:59Z")

</div>

@Colin . Apologies for the late reply. I was on a business trip and just returned. Good news.....IT VERKS perfectly! I appreciate your help. It amazes me that, more often than not, open source software is of higher quality and better supported then paid software! If you ever need help with a chemical engineering problem, I realize that is probably unlikely but none-the-less, I owe you. Thanks again....Mike.

---

<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:** [16 September 2023 05:21 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/57 "2023-09-16T05:21:12Z")

</div>

I do not want to leave anyone out.....thank you @dceejay. The above message applies to you too.

---

<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:** [16 September 2023 07:08 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/58 "2023-09-16T07:08:35Z")

</div>

> [@gil27255](#):
>
> I do not want to leave anyone out.....thank you @dceejay

Quite right, the fix was down to Dave.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [30 September 2023 07:09 UTC](https://discourse.nodered.org/t/text-input-time-picker-returns-incorrect-ms-from-midnight/80772/59 "2023-09-30T07:09:08Z")

</div>

Closed on 30 September 2023 07:09 UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

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