# Changing timestamp formats

**URL:** <https://discourse.nodered.org/t/changing-timestamp-formats/77501>\
**Category:** General\
**Created:** [12 April 2023 17:50 UTC](https://discourse.nodered.org/t/changing-timestamp-formats/77501 "2023-04-12T17:50:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fuchshunde](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fuchshunde/32/78790_2.png) [@Fuchshunde](https://discourse.nodered.org/u/Fuchshunde)\
**Post date:** [12 April 2023 17:50 UTC](https://discourse.nodered.org/t/changing-timestamp-formats/77501/1 "2023-04-12T17:50:22Z")

</div>

Hey everyone,

Can someone help me to change two timestamps with the following Format (Start: "2013-02-04T22:44:30.652Z", End: 2013-02-07T22:44:30.652Z ) into (Start: "04.02.2013", End: "07.02.2013")? Is it possible by using a function node for that? I know, that there is the moment-node for this operation, but i don't want to split my two date into two payloads and join them together again to form one payload.

King regards  
Marcus

---

<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:** [12 April 2023 17:56 UTC](https://discourse.nodered.org/t/changing-timestamp-formats/77501/2 "2023-04-12T17:56:58Z")

</div>

Presumming your example is in msg.payload.  
In a change node  
set `msg.` `payload.Start`  
to, select JSONata J:  
`$moment($$.payload.Start).format("DD.MM.YYYY")`  
Repeat for end.  
Make sure the payload is an object and not a JSON string, you can use a json node to switch between either, or some nodes allow you to select a parse object as the output format.

---

<div class="post-metadata">

**Author:** ![Fuchshunde](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fuchshunde/32/78790_2.png) [@Fuchshunde](https://discourse.nodered.org/u/Fuchshunde)\
**Post date:** [12 April 2023 18:13 UTC](https://discourse.nodered.org/t/changing-timestamp-formats/77501/3 "2023-04-12T18:13:23Z")

</div>

Hey E1cid,

Thanks a lot for your fast reply! I tried it and it worked perfectly.

---

<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:** [26 April 2023 18:14 UTC](https://discourse.nodered.org/t/changing-timestamp-formats/77501/4 "2023-04-26T18:14:16Z")

</div>

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