# Needing help with formatting j$ things

**URL:** <https://discourse.nodered.org/t/needing-help-with-formatting-j-things/88551>\
**Category:** General\
**Created:** [7 June 2024 23:27 UTC](https://discourse.nodered.org/t/needing-help-with-formatting-j-things/88551 "2024-06-07T23:27:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 June 2024 23:27 UTC](https://discourse.nodered.org/t/needing-help-with-formatting-j-things/88551/1 "2024-06-07T23:27:23Z")

</div>

Sorry folks.

I can't seem to get it.

I have this:

```auto
[
    {
        "id": "b5fa13f755ec33fe",
        "type": "change",
        "z": "235f16ee6e459f2c",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$moment().tz(\"Australia/Sydney\").format(\"H:m:s\")",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$split($$.payload, \":\").$formatInteger($number($), \"w\")",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 4180,
        "y": 3550,
        "wires": [
            []
        ]
    }
]

```

Which is good. It works.

BUT - yeah, there is one.

I would also like to get the time (hours minutes seconds) as integer numbers as/in another part of the message.

So, say `msg.time`.  
(Can be an array or structure.)

Just I need to so stuff at/in the next node and it would be easier if I had the numeric values rather than the text values - which are still needed.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [8 June 2024 00:56 UTC](https://discourse.nodered.org/t/needing-help-with-formatting-j-things/88551/2 "2024-06-08T00:56:33Z")

</div>

Worked it out - eventually.

This code did the trick.

```auto
let x = msg.time.split(":")

msg.hour = parseInt(x[0])
msg.minute = parseInt(x[1])
msg.second = parseInt(x[2])

//------------------
// New stuff added 2024 06 08
if (msg.hour < 10)
{
    // less than 10. Add leading *zero*
    node.warn("hour")
    msg.hour = "zero " + msg.payload[0]
}

if (msg.minute < 10)
{
    // less than 10. Add leading *zero*
    node.warn("minute")
    msg.minute = "zero " + msg.minute
}

if (msg.second < 10)
{
    // less than 10. Add leading *zero*
    node.warn("second")
    msg.second = "zero " + msg.payload[2]
}

//------------------

if (msg.minute == 0)
{
    msg.minute = " hundred "
    //return msg;
}

if (msg.second == 0)
{
    msg.second = "exactly"
} else
msg.second = "and " + msg.second + " seconds"

return msg;

```

---

<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:** [22 June 2024 00:57 UTC](https://discourse.nodered.org/t/needing-help-with-formatting-j-things/88551/3 "2024-06-22T00:57:23Z")

</div>

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