# Moment msg.outTz does not work

**URL:** <https://discourse.nodered.org/t/moment-msg-outtz-does-not-work/96844>\
**Category:** General\
**Tags:** node-red-contrib-moment, moment\
**Created:** [2 May 2025 00:36 UTC](https://discourse.nodered.org/t/moment-msg-outtz-does-not-work/96844 "2025-05-02T00:36:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigbean17](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bigbean17/32/89814_2.png) [@bigbean17](https://discourse.nodered.org/u/bigbean17)\
**Post date:** [2 May 2025 00:36 UTC](https://discourse.nodered.org/t/moment-msg-outtz-does-not-work/96844/1 "2025-05-02T00:36:29Z")

</div>

Hi,

I'm trying to dynamically set the outTz from an input node by `msg.outTz`, but seems like the moment node does not pick up the outTz, seems like it still uses the default timezone (probably from browser?)

Here are my code, no matter what timezone outTz has, it wont change

```auto
[
    {
        "id": "2c5752fea8ababd1",
        "type": "inject",
        "z": "b8212410faeba9d9",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "outTz",
                "v": "UTC",
                "vt": "str"
            },
            {
                "p": "inTz",
                "v": "Australia/Sydney",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "topic": "",
        "payload": "1745919002581",
        "payloadType": "str",
        "x": 1120,
        "y": 160,
        "wires": [
            [
                "e6f5211b91ce70fa"
            ]
        ]
    },
    {
        "id": "05dc9b47e23fa604",
        "type": "debug",
        "z": "b8212410faeba9d9",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1620,
        "y": 160,
        "wires": []
    },
    {
        "id": "e6f5211b91ce70fa",
        "type": "moment",
        "z": "b8212410faeba9d9",
        "name": "",
        "topic": "",
        "input": "payload",
        "inputType": "msg",
        "inTz": "''",
        "adjAmount": 0,
        "adjType": "days",
        "adjDir": "add",
        "format": "",
        "locale": "en-AU",
        "output": "payload",
        "outputType": "msg",
        "outTz": "''",
        "x": 1360,
        "y": 160,
        "wires": [
            [
                "05dc9b47e23fa604"
            ]
        ]
    }
]

```

Thanks for helping!

---

<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:** [2 May 2025 06:50 UTC](https://discourse.nodered.org/t/moment-msg-outtz-does-not-work/96844/2 "2025-05-02T06:50:49Z")

</div>

Why not do it direct in the change node using $moment function of JSONata.

Your input is already in utc as that is the epoch timestamp (1745919002581). you can set the timezone of the output using the tz() function of moment functions

```auto
[{"id":"2c5752fea8ababd1","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"outTz","v":"UTC","vt":"str"},{"p":"inTz","v":"Australia/Sydney","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"","topic":"","payload":"1745919002581","payloadType":"num","x":420,"y":4940,"wires":[["d317dc9e7eb1ba07"]]},{"id":"05dc9b47e23fa604","type":"debug","z":"d1395164b4eec73e","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":920,"y":4940,"wires":[]},{"id":"d317dc9e7eb1ba07","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$moment($$.payload).tz($$.outTz)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":4940,"wires":[["05dc9b47e23fa604"]]}]

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [2 May 2025 08:31 UTC](https://discourse.nodered.org/t/moment-msg-outtz-does-not-work/96844/3 "2025-05-02T08:31:20Z")

</div>

Just to say that the moment custom node hasn't had any updates in a long time now (mea culpa!). As already noted, you can use moment in JSONata these days or in a function node.

---

<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:** [16 May 2025 08:31 UTC](https://discourse.nodered.org/t/moment-msg-outtz-does-not-work/96844/4 "2025-05-16T08:31:45Z")

</div>

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