Unuasual timeStamp: "230222072038" to normal timestamp

Hi,

From my smartmeter I get a string with this timestamp: 230222075216
Wich stands for YYMMDDHHMMSS.
I looked at other posts on this forum, but can't realy fugure out how to turn this into a normal timestamp that I can use.

The idea is to save it all into google sheets for record purposes, now google sheets can't make much of this timestamp.
image

Any suggestions?

Here is an example flow with the use of $moment jsonata expression in a Change node.
The bottom part of the flow is similar but shows how to also change the time to a different format.

[{"id":"ccd97c0c1c95efde","type":"inject","z":"54efb553244c241f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"230222075216","payloadType":"str","x":300,"y":2260,"wires":[["5cadc308ae7d4ae9","8629d146ad8213ef"]]},{"id":"5cadc308ae7d4ae9","type":"change","z":"54efb553244c241f","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$moment(payload, \"YYMMDDHHmmss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":2200,"wires":[["51170b658254bc1b"]]},{"id":"51170b658254bc1b","type":"debug","z":"54efb553244c241f","name":"debug 26","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":2200,"wires":[]},{"id":"8629d146ad8213ef","type":"change","z":"54efb553244c241f","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$moment(payload, \"YYMMDDHHmmss\").format(\"DD-MM-YYYY HH:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":2300,"wires":[["653ae46d288970d7"]]},{"id":"653ae46d288970d7","type":"debug","z":"54efb553244c241f","name":"debug 27","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":2300,"wires":[]}]

JUst to add to @UnborN answer
You can add .format() to return an ISO timestamp.

$moment($$.payload, "YYMMDDHHmmss").format()

should return

2023-02-22T07:52:16+00:00

or

$moment($$.payload, "YYMMDDHHmmss").utc().format()

to retuurn a UTC zulu timestamp

2023-02-22T07:52:16Z
1 Like

Or try the moment node. :wink:

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