Node-red date picker issue

I'm using node-red version 3.0.2. I observe that the date-picker node returns a random time on the date I select. This does not work for me (I want to add a specific time to the date). I observe that in github this problem was report on jul 10 of 2020 and was fixed, committed and merged the same day. But my installation is not doing what the committed code does (set hours, minutes, and seconds to 0 on the selected day).

Does anyone know why this is not working and what I can do to get it to work correctly?

See Date Picker should return 12:00:00 AM GMT of date selected · Issue #599 · node-red/node-red-dashboard · GitHub

I was mistaken in my original assessment.My confusion was caused by me having an inject node to set up the default date and not realizing that the time from that injection set a time that was then reused by the date picker node.

I do believe, however, that there is still a different issue...when picking a date, the date that is displayed on the calendar is sometimes one day less than the date that is output by the node. This appears to be somehow related to the users local timezone. I note that the date/time picker in the text input node does not have this behavior...it always outputs the exact day and time that is selected in UTC. I think that the date picker should behave the same way as the date/time picker. Perhaps with an option (for UTC), to avoid breaking existing flows?

Can you provide two flows and the steps to take to demonstrate the issue? That would make it easier for someone to look at it.

Example: To duplicate, select the same date in both and see the debug output.

[
    {
        "id": "b5ce62e98aad3eee",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "a418eaf02ae38ac1",
        "type": "ui_date_picker",
        "z": "b5ce62e98aad3eee",
        "name": "",
        "label": "test",
        "group": "3d19d6bf7e0f488d",
        "order": 0,
        "width": 0,
        "height": 0,
        "passthru": true,
        "topic": "topic",
        "topicType": "msg",
        "className": "",
        "x": 290,
        "y": 160,
        "wires": [
            [
                "96347a4b0a6c5163"
            ]
        ]
    },
    {
        "id": "96347a4b0a6c5163",
        "type": "debug",
        "z": "b5ce62e98aad3eee",
        "name": "debug 9",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 480,
        "y": 160,
        "wires": []
    },
    {
        "id": "4fc1d2693c80c7dd",
        "type": "ui_text_input",
        "z": "b5ce62e98aad3eee",
        "name": "",
        "label": "",
        "tooltip": "",
        "group": "3d19d6bf7e0f488d",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": false,
        "mode": "datetime-local",
        "delay": "0",
        "topic": "topic",
        "sendOnBlur": true,
        "className": "",
        "topicType": "msg",
        "x": 330,
        "y": 280,
        "wires": [
            [
                "23e89604f744f512"
            ]
        ]
    },
    {
        "id": "23e89604f744f512",
        "type": "debug",
        "z": "b5ce62e98aad3eee",
        "name": "debug 10",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 540,
        "y": 280,
        "wires": []
    },
    {
        "id": "3d19d6bf7e0f488d",
        "type": "ui_group",
        "name": "test",
        "tab": "ddc03e87399db61c",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "ddc03e87399db61c",
        "type": "ui_tab",
        "name": "Test",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

Another way to state this issue: The date picker node seems to be aware of the local time zone and adjusts the output accordingly. The datetime picker in the text node does not adjust its output based on local time zone.

What do you have set in the dashboard Date Format?
dashboard-date-format

After playing I think what is happening is that what ever input you enter in the data/time picker, it is assuming that input is UTC-0 not your current UTC. For example I'm in UTC-4 but it I enter April 1st at 1:05 AM it must be assuming the date entered is n UTC time so it displays as 4 hours earlier because of my being in UTC-4

@dceejay any thoughts about this?

yes - something definitely slightly off... I haven't had a chance to dig into both scenarios - and which should be the "correct" answer. The intention of the date picker was to return the date (12 midnight of that day). - but there also seems to be some quirkiness about the hour shift of daylight saving time - if you select a day before or after the recent shift - so it's not simple.

Personally I think that the date-time picker is always doing the "correct" thing with the date that it generates. I'd like to see the date picker have an option to "use UTC" (like the chart node has) to behave the same way, (if it is necessary to retain the current [strange] behavior for backwards compatibility) . It appears that the local time zone somehow impacts the date picker, but not the date-time picker. If you inject a date with various times into the date picker, I notice that output date can change in subsequent selections on the GUI, again a function of my time zone....

@zenofmud : Thanks for the hint on the date format. I'm also in UTC-4 and I note that when within 4 hours of midnight the date picker seems to select the next day (which it is in GMT).

In my application I just want the user to select the UTC date so that the correct data file will be opened to display the data. The filenames are of the form xxxx-YYYY-MM-DD so getting a date other than the one selected is undesired. Using the date-time picker is awkward because its interface is more cumbersome and in my case the time is not needed.

@dceejay any chance you might find time to look at this? Thanks.

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