# Convert date format

**URL:** <https://discourse.nodered.org/t/convert-date-format/87755>\
**Category:** General\
**Created:** [6 May 2024 15:01 UTC](https://discourse.nodered.org/t/convert-date-format/87755 "2024-05-06T15:01:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pierredemay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pierredemay/32/90948_2.png) [@pierredemay](https://discourse.nodered.org/u/pierredemay)\
**Post date:** [6 May 2024 15:01 UTC](https://discourse.nodered.org/t/convert-date-format/87755/1 "2024-05-06T15:01:00Z")

</div>

Hi there,

I would like to know how to convert a date like "4/15/24" into the french date format (15/04/2024).

Did someone can help me ? Thank you !

---

<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:** [6 May 2024 16:39 UTC](https://discourse.nodered.org/t/convert-date-format/87755/2 "2024-05-06T16:39:33Z")

</div>

There are many methods and you will probably be shown ma few here.  
here is one example using JSONata in a change node and $moment function.

```auto
[{"id":"01acdd89f66bb827","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"16/4/2024","payloadType":"str","x":580,"y":7520,"wires":[["e0dde8a41aca926e"]]},{"id":"e0dde8a41aca926e","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$moment($$.payload, \"DD/MM/YYYY\").format(\"MM/DD/YYYY\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":7520,"wires":[["d7b19d3d98864701"]]},{"id":"d7b19d3d98864701","type":"debug","z":"d1395164b4eec73e","name":"debug 2520","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":7520,"wires":[]}]

```

expression

```auto
$moment($$.payload, "DD/MM/YYYY").format("MM/DD/YYYY")

```

More info on moment here [Moment.js | Docs](https://momentjs.com/docs/#/displaying/)

---

<div class="post-metadata">

**Author:** ![pierredemay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pierredemay/32/90948_2.png) [@pierredemay](https://discourse.nodered.org/u/pierredemay)\
**Post date:** [7 May 2024 07:55 UTC](https://discourse.nodered.org/t/convert-date-format/87755/3 "2024-05-07T07:55:15Z")

</div>

Hey E1cid,

I've just tried it and it works perfectly !

Thanks.

---

<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:** [5 August 2024 07:56 UTC](https://discourse.nodered.org/t/convert-date-format/87755/4 "2024-08-05T07:56:03Z")

</div>

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