# Time formating convert

**URL:** <https://discourse.nodered.org/t/time-formating-convert/77258>\
**Category:** General\
**Created:** [5 April 2023 06:36 UTC](https://discourse.nodered.org/t/time-formating-convert/77258 "2023-04-05T06:36:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![soerenbull](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@soerenbull](https://discourse.nodered.org/u/soerenbull)\
**Post date:** [5 April 2023 06:36 UTC](https://discourse.nodered.org/t/time-formating-convert/77258/1 "2023-04-05T06:36:34Z")

</div>

Hey.

Still a newbie to node red 🙂

i maneged to get my PLC time function to work with the help of this topic:

> [@Formating input signal into Time Format](https://discourse.nodered.org/t/formating-input-signal-into-time-format/41544):
>
> Hi, I am completely new to Node Red and want to use it to integrate some PLC Logic into HomeAssistant. My PLC is a Siemens LOGO!8 which controlls light and temperature of some terrariums - while HomeAssistant should be a "nice Dashboard" with other integrations. I would like to display some parameters of the PLC control on this Dashboard (for now, only displaying, not controlling anything in LOGO) I've got the NodeRed integration into HomeAssistant working - and also the connection to my LOGO…

So now i can read the time value from my PLC  
The code for function block is:

```auto
var asHex = parseInt(msg.payload).toString("16").padStart(4, "0");
var hh = asHex.substring(0, 2);
var mm = asHex.substring(2, 4);
msg.payload = `${hh}:${mm}`
return msg;

```

But can someone help me re-write the function code so i can send / edit the time value in PLC ?

 ![flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/50a2f54e13b10c21832478423af268ef7187ffdd.png)

---

<div class="post-metadata">

**Author:** ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)\
**Post date:** [5 April 2023 10:56 UTC](https://discourse.nodered.org/t/time-formating-convert/77258/2 "2023-04-05T10:56:23Z")

</div>

Node-red-contrib-moment provides a node that easily formats time into any form you want. If you are looking specifically how to send time to plc someone else will have weigh in.

---

<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:** [4 June 2023 10:56 UTC](https://discourse.nodered.org/t/time-formating-convert/77258/3 "2023-06-04T10:56:37Z")

</div>

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