I configurated a ui_Form with an Input Field of type "Date".
The output of Date is always one day backwards to what i picked.(e.g picked 12.03.2020 - > Output : 11.03.2020)
How can i get the same Date i picked as Outout?
I configurated a ui_Form with an Input Field of type "Date".
The output of Date is always one day backwards to what i picked.(e.g picked 12.03.2020 - > Output : 11.03.2020)
How can i get the same Date i picked as Outout?
Feed the output into a debug node and show us what it says
2020-09-18T22:00:00.000Z
Input was 19.09.2020.
i think its something about the "Z" after time
What timezone are you, and what time was it?
My RPI is running UTC+1
Can you run, in a terminal,
node-red-stop
node-red-start
And copy/paste the result here. Use the </>
button and paste the text in.
Once Node-RED has started, point a browser at http://192.168.178.35:1880
On Pi Node-RED works better with the Firefox or Chrome browser
Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot
To find more nodes and example flows - go to http://flows.nodered.org
Starting as a systemd service.
6 Sep 19:21:50 - [info]
Welcome to Node-RED
===================
6 Sep 19:21:50 - [info] Node-RED version: v1.1.0
6 Sep 19:21:50 - [info] Node.js version: v12.17.0
6 Sep 19:21:50 - [info] Linux 4.19.118-v7+ arm LE
6 Sep 19:21:51 - [info] Loading palette nodes
6 Sep 19:22:02 - [info] Worldmap version 2.0.18
6 Sep 19:22:03 - [info] Dashboard version 2.23.0 started at /ui
6 Sep 19:22:05 - [info] Settings file : /home/pi/.node-red/settings.js
6 Sep 19:22:05 - [info] Context store : 'default' [module=memory]
6 Sep 19:22:05 - [info] User directory : /home/pi/.node-red
6 Sep 19:22:05 - [warn] Projects disabled : editorTheme.projects.enabled=false
6 Sep 19:22:05 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
6 Sep 19:22:05 - [info] Server now running at http://127.0.0.1:1880/
6 Sep 19:22:05 - [warn]
It would be worth upgrading node-red to the latest, there were some issues with 1.1.0, though I don't expect it to be the problem here (sudo npm install -g --unsafe-perm node-red
) then restart node-red.
Also upgrade the dashboard, which you can do via Manage Palette, though I am not hopeful that will help either.
What browser are you using and can you try a different one?
I ran the update but as expected no difference
And the browser question?
Same on Vivaldi Browser.
I tried it also running node-red on WIndows...same here
Odd, can you export a mini flow just consisting of the ui nodes needed and a debug node that shows the problem?
[{"id":"2011d220.e28e8e","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"ae565e9b.4a724","type":"ui_form","z":"2011d220.e28e8e","name":"","label":"Date in Form","group":"5a80f7fa.fb5098","order":2,"width":"0","height":"0","options":[{"label":"Datum","value":"Datum","type":"date","required":true,"rows":null}],"formValue":{"Datum":""},"payload":"","submit":"submit","cancel":"cancel","topic":"","x":330,"y":200,"wires":[["deaad8a1.fb7b48"]]},{"id":"deaad8a1.fb7b48","type":"ui_text","z":"2011d220.e28e8e","group":"5a80f7fa.fb5098","order":1,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","x":560,"y":200,"wires":[]},{"id":"5a80f7fa.fb5098","type":"ui_group","z":"","name":"Date(Form)","tab":"449bd675.359ec8","order":1,"disp":true,"width":"6","collapse":false},{"id":"449bd675.359ec8","type":"ui_tab","z":"","name":"TestTaB","icon":"dashboard","order":4,"disabled":false,"hidden":false}]
Try updating dashboard to latest. There was a fix around the date picker which I believe was added just after release of v2.23.0
@knubbl indicated that he had already updated the dashboard, I suggested that earlier, but perhaps it was not done.
Date picker is working fine.
The problem is the ui_form in which i put a date input field
Can you confirm that you have updated the dashboard? Also confirm what you see from the flow you posted and the timezone of the machines running the browser and node red.
For me, when I enter 19/09/20 it gives {"Datum":"2020-09-18T23:00:00.000Z"}
which is a timestamp for the start of the day in local time (23:00 on 18th UTC, which is midnight UTC+1), which I assume is what the node is supposed to provide.
Demo...
Chosen date was 2020/09/06...
... times are output in UTC, I am in UTC+1 (so add the offset and you get 00:00 of the correct date)
The issue is purely visual - the date / time is in-fact correct, merely represented as UTC.
If need be, you can use a function like below to get a local date/time representation...
function convertUTCDateToLocalDate(date) {
var newDate = new Date(date.getTime()+date.getTimezoneOffset()*60*1000);
var offset = date.getTimezoneOffset() / 60;
var hours = date.getHours();
newDate.setHours(hours - offset);
return newDate;
}
Get the following error message
TypeError: date.getTime is not a function
This means your date
is not a date object (It is likely an epoch or string)
Try this instead...
Flow to import...
[{"id":"35156752.400eb8","type":"function","z":"ebd0d71c.0bad18","name":"date parser","func":"\nlet d = new Date(msg.payload.date)\nlet dateTimeLocal = new Date(d.getTime() - (d.getTimezoneOffset() * 60000)).toISOString().slice(0,23).replace(\"T\",\" \");\nlet dateLocal = dateTimeLocal.slice(0,10)\nmsg.payload = {\n dateObject: d,\n dateTimeLocal: dateTimeLocal,\n dateLocal: dateLocal,\n}\nreturn msg;","outputs":1,"noerr":0,"x":1110,"y":140,"wires":[["fcb55760.fde188"]]},{"id":"ef045e1a.6dddb","type":"ui_form","z":"ebd0d71c.0bad18","name":"","label":"","group":"376c9cdf.3d0184","order":0,"width":0,"height":0,"options":[{"label":"date","value":"date","type":"date","required":true,"rows":null}],"formValue":{"date":""},"payload":"","submit":"submit","cancel":"cancel","topic":"","x":1050,"y":100,"wires":[["35156752.400eb8"]]},{"id":"fcb55760.fde188","type":"debug","z":"ebd0d71c.0bad18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1170,"y":180,"wires":[]},{"id":"376c9cdf.3d0184","type":"ui_group","z":"","name":"UserEntry","tab":"4af0eb21.b30c04","order":1,"disp":true,"width":"6","collapse":false},{"id":"4af0eb21.b30c04","type":"ui_tab","z":"","name":"Home","icon":"home","order":1}]