Get time and date on raspberry

hello my friends can i'm wondering how to get time and date to a text node using a function node when working on raspberry pi ? thanks.

You could use Angular and format the timestamp in the text node value input
{{msg.payload| date : "dd-MM-yyyy HH:mm:ss" }}

[{"id":"691636cb.ea6028","type":"inject","z":"5a245aa1.510164","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":270,"y":3780,"wires":[["1a4503eb.b9f6c4"]]},{"id":"1a4503eb.b9f6c4","type":"ui_text","z":"5a245aa1.510164","group":"8b5cde76.edd58","order":4,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload| date  : \"dd-MM-yyyy HH:mm:ss\" }}","layout":"row-spread","x":420,"y":3780,"wires":[]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"6","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

it doesn't work my friend i tried it in both windows and raspberry pi
there is one detail that i forgot to mention it that i've been working on windows and i ve used this script in a function var now = new Date().toLocaleString("en-EN"); return {payload: now}; and it worked well but it doesn't on raspberry pi

i'm sorry it was so rediculous from me not to click on timestamp button it worked fine .
thank u very much

That's likely due to node version difference.

What version does windows have (my money is on v14) and what version node on pi? (I guess V12 or below)

no my friend that method does work too but like i said it was silly of m not pressing the timestamp's button

1 Like

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