# Debug node - $moment() utc vs. local time

**URL:** <https://discourse.nodered.org/t/debug-node-moment-utc-vs-local-time/53673>\
**Category:** General\
**Created:** [13 November 2021 11:53 UTC](https://discourse.nodered.org/t/debug-node-moment-utc-vs-local-time/53673 "2021-11-13T11:53:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ACrazyConcept](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/acrazyconcept/32/51000_2.png) [@ACrazyConcept](https://discourse.nodered.org/u/ACrazyConcept)\
**Post date:** [13 November 2021 11:53 UTC](https://discourse.nodered.org/t/debug-node-moment-utc-vs-local-time/53673/1 "2021-11-13T11:53:00Z")

</div>

I am trying to create a debug message with time. I found the `$moment()` function and it does give me the local time. But when I add text to the message e.g. `"text" & $moment()` the function suddenly prints UTC time instead.

So how can I create a message with the local time?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8aa5477705ff165e541a9e4e542ce5f71e16b41c.png)

---

<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:** [13 November 2021 12:06 UTC](https://discourse.nodered.org/t/debug-node-moment-utc-vs-local-time/53673/2 "2021-11-13T12:06:47Z")

</div>

If you just want the utc timestamp, I would just use $now(). If you want to use moment, then format the string  
e.g.

```auto
[{"id":"321e49fa.dfa2d6","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"text\" & $moment().format(\"YYY-MM-DD HH:mm:ss.SSS\")","payloadType":"jsonata","x":480,"y":1440,"wires":[["aed0b560.56a7a8"]]},{"id":"aed0b560.56a7a8","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":710,"y":1440,"wires":[]},{"id":"81d7f489.3d8cf8","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"text\" & $now()","payloadType":"jsonata","x":490,"y":1480,"wires":[["aed0b560.56a7a8"]]}]

```

`"text" & $now()`  
`"text" & $moment().format("YYY-MM-DD HH:mm:ss.SSS")`  
Moments is becoming depreciated.

---

<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:** [12 January 2022 12:07 UTC](https://discourse.nodered.org/t/debug-node-moment-utc-vs-local-time/53673/3 "2022-01-12T12:07:46Z")

</div>

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