# How to use the "moment" node?

**URL:** <https://discourse.nodered.org/t/how-to-use-the-moment-node/19481>\
**Category:** General\
**Created:** [22 December 2019 20:32 UTC](https://discourse.nodered.org/t/how-to-use-the-moment-node/19481 "2019-12-22T20:32:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)\
**Post date:** [22 December 2019 20:32 UTC](https://discourse.nodered.org/t/how-to-use-the-moment-node/19481/1 "2019-12-22T20:32:33Z")

</div>

Hi,

I am looking for some examples to get a readable datetime format out of the "moment" node.  
I need something I can passthrough to my MS-SQL Server - the datetime format is defined like that:  
2019-12-22 20:27:39.012

All I get from the moment node is: 2019-12-22T21:27:39.167Z  
The format is wrong and its giving my the wrong time zone ☹

Do I really have to parse this output sign by sign and re-format it ? or is there any functionality I could use ?

BR  
Gawan

---

<div class="post-metadata">

**Author:** ![hominidae](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hominidae/32/4174_2.png) [@hominidae](https://discourse.nodered.org/u/hominidae)\
**Post date:** [22 December 2019 21:20 UTC](https://discourse.nodered.org/t/how-to-use-the-moment-node/19481/2 "2019-12-22T21:20:43Z")

</div>

...the output format ist documented here, as already linked in the node description: [https://momentjs.com/docs/#/displaying/format/](https://momentjs.com/docs/#/displaying/format/)

My guess is, that what you want is something like "YYYY-MM-DD HH.mm.ss.SS" in the output format section of the node.  
Just feed a suitable time object into it via the payload, i.e. create from a function node with "msg.payload = new Date().toISOString();".

Here's a mini flow:

```auto
[{"id":"48703c49.cf7214","type":"function","z":"90f78b.543da878","name":"timestamp","func":"msg.payload = new Date().toISOString();\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":420,"wires":[["3e4ccaf8.9d2526"]]},{"id":"3e4ccaf8.9d2526","type":"moment","z":"90f78b.543da878","name":"dd DD.MM.YY - HH:mm","topic":"date","input":"payload","inputType":"msg","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"dd DD.MM.YY - HH:mm","locale":"DE","output":"payload","outputType":"msg","outTz":"Europe/Berlin","x":590,"y":480,"wires":[["47c2ee55.7a954"]]}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 December 2019 21:58 UTC](https://discourse.nodered.org/t/how-to-use-the-moment-node/19481/3 "2019-12-22T21:58:07Z")

</div>

I believe the node will allow a raw timestamp value to be input, there is no point converting it to a string for the node then to convert it back to a timestamp in order to format it as required. So you can just use `msg.payload = new Date()`

---

<div class="post-metadata">

**Author:** ![Gawan](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Gawan](https://discourse.nodered.org/u/Gawan)\
**Post date:** [22 December 2019 22:01 UTC](https://discourse.nodered.org/t/how-to-use-the-moment-node/19481/4 "2019-12-22T22:01:36Z")

</div>

thats exactly what I need !

YYYY-MM-DD HH:mm:ss.sss

perfect, thanks a lot guys !!
