# Unuasual timeStamp: "230222072038" to normal timestamp

**URL:** https://discourse.nodered.org/t/unuasual-timestamp-230222072038-to-normal-timestamp/75565
**Category:** General
**Tags:** function-node
**Created:** [22 February 2023 07:16 UTC](https://discourse.nodered.org/t/unuasual-timestamp-230222072038-to-normal-timestamp/75565 "2023-02-22T07:16:18Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Nice\_to\_have](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@Nice\_to\_have](https://discourse.nodered.org/u/Nice_to_have)
#### Post date: [22 February 2023 07:16 UTC](https://discourse.nodered.org/t/unuasual-timestamp-230222072038-to-normal-timestamp/75565/1 "2023-02-22T07:16:18Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/c/8cda5dcad9f98e12f8df517dda6022b6a57deac9.png)

Any suggestions?

---

<div class="post-metadata">

### Author: ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)
#### Post date: [22 February 2023 07:37 UTC](https://discourse.nodered.org/t/unuasual-timestamp-230222072038-to-normal-timestamp/75565/2 "2023-02-22T07:37:48Z")

</div>

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.

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [22 February 2023 07:43 UTC](https://discourse.nodered.org/t/unuasual-timestamp-230222072038-to-normal-timestamp/75565/3 "2023-02-22T07:43:28Z")

</div>

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

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

```

should return

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

```

or

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

```

to retuurn a UTC zulu timestamp

```auto
2023-02-22T07:52:16Z

```

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [22 February 2023 07:44 UTC](https://discourse.nodered.org/t/unuasual-timestamp-230222072038-to-normal-timestamp/75565/4 "2023-02-22T07:44:57Z")

</div>

Or try the `moment` node. 😉

---

<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: [8 March 2023 07:45 UTC](https://discourse.nodered.org/t/unuasual-timestamp-230222072038-to-normal-timestamp/75565/5 "2023-03-08T07:45:38Z")

</div>

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