# Help with splitting payload (to get the values for the time)

**URL:** https://discourse.nodered.org/t/help-with-splitting-payload-to-get-the-values-for-the-time/86303
**Category:** General
**Created:** [9 March 2024 23:21 UTC](https://discourse.nodered.org/t/help-with-splitting-payload-to-get-the-values-for-the-time/86303 "2024-03-09T23:21:10Z")
**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: [9 March 2024 23:21 UTC](https://discourse.nodered.org/t/help-with-splitting-payload-to-get-the-values-for-the-time/86303/1 "2024-03-09T23:21:10Z")

</div>

This is what I have so far but it doesn't work as I want.

```auto
[{"id":"943ee548ae140c50","type":"change","z":"235f16ee6e459f2c","name":"TimeStamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":3400,"y":1420,"wires":[["c8db866e84b556ab"]]},{"id":"c8db866e84b556ab","type":"moment","z":"235f16ee6e459f2c","name":"","topic":"","input":"payload","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm:ss","locale":"en_AU","output":"payload","outputType":"msg","outTz":"Australia/Sydney","x":3590,"y":1420,"wires":[["46a337239c34a502"]]},{"id":"46a337239c34a502","type":"template","z":"235f16ee6e459f2c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"The time is {{payload}}","output":"str","x":3780,"y":1420,"wires":[["91699b85b4e6a7d6"]]}]

```

When I put it through the `text to speech` it comes out a bit yucky.

I want it to be more like how you would say the time.

And - sorry but _sod's law_ is here - if the second value (for the seconds) is `0` I want `exactly` said rather than `zero`.

I'm guessing I need to parse the `payload` out of the `date/time formatter` node and split it into `hours` `minutes` and `seconds`.

I'll do local digging too, but just of someone doesn't mind.

---

<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: [9 March 2024 23:32 UTC](https://discourse.nodered.org/t/help-with-splitting-payload-to-get-the-values-for-the-time/86303/2 "2024-03-09T23:32:08Z")

</div>

These two nodes seem to be doing it.

```auto
[{"id":"78a97b936514a7b7","type":"function","z":"b25fd092.bcc758","name":"function 40","func":"let x = msg.payload.split(\":\")\n\n//node.warn(x);\n\nmsg.hour = x[0];\nmsg.minute = x[1];\nmsg.second = x[2];\n\nif (msg.second == 0)\n{\n msg.second = \"exactly\";\n} else\nmsg.second = \" and \" + x[2] + \" seconds\";\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2030,"y":310,"wires":[["c027723a8de504df","945027a34e67375e"]]},{"id":"945027a34e67375e","type":"template","z":"b25fd092.bcc758","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"The time is {{hour}} {{minute}} {{second}}","output":"str","x":1920,"y":370,"wires":[["cd12799f4f8a921d"]]}]

```

---

<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: [23 March 2024 23:32 UTC](https://discourse.nodered.org/t/help-with-splitting-payload-to-get-the-values-for-the-time/86303/3 "2024-03-23T23:32:49Z")

</div>

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