Convert date format

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 !

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.

[{"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

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

More info on moment here Moment.js | Docs

Hey E1cid,

I've just tried it and it works perfectly !

Thanks.

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