# Formating input signal into Time Format

**URL:** <https://discourse.nodered.org/t/formating-input-signal-into-time-format/41544>\
**Category:** General\
**Created:** [24 February 2021 12:23 UTC](https://discourse.nodered.org/t/formating-input-signal-into-time-format/41544 "2021-02-24T12:23:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChristophCaina](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christophcaina/32/37783_2.png) [@ChristophCaina](https://discourse.nodered.org/u/ChristophCaina)\
**Post date:** [24 February 2021 12:23 UTC](https://discourse.nodered.org/t/formating-input-signal-into-time-format/41544/1 "2021-02-24T12:23:47Z")

</div>

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 Hardware.  
This is fine - and I am also able to display the Status of some Sensors, and stuff like this.

Now, comming to my main issue:

On my LOGO, I have an astronomical clock running, which is checking for Sunrise and Sunset to trigger, when the lights should go on and off.

On the LOGO Display, I can see the correct time format:  
 ![2021-02-24 13_05_36-LOGO! TD](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/1/a19341ef0927fc9c386a9c4c4681b654b3860ae6.png)

Sunrise: 07:04 AM  
Sunset: 05:37 PM (17:37)

But if I'm trying to get the value of this block in NodeRed, I am getting:  
 ![2021-02-24 13_05_10-Node-RED - Home Assistant](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/0/80e5628d052062ef25acd380125fc00dca89e983.png)  
Sunrise: 1796  
Sunset: 5943

Any Idea, what I need to do to get the same output as in the LOGO Display?  
Any kind of calculation or formatting?

Honestly, I were not able to figure out, what kind of format the output from my logo SHOULD be (it's not seconds or minutes, or anything that I could convert into a date/time format)

Thanks a lot and with best regards,  
Christoph

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 February 2021 13:51 UTC](https://discourse.nodered.org/t/formating-input-signal-into-time-format/41544/2 "2021-02-24T13:51:09Z")

</div>

Those values are decimal & if you convert to hex you will see the time.

1796 == 0x704  
5943 == 0x1737

here is a demo  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/3/53943620aa8b6af562eb98b5c67b1c2e7bf65f31.png)

function code...

```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;

```

---

<div class="post-metadata">

**Author:** ![ChristophCaina](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/christophcaina/32/37783_2.png) [@ChristophCaina](https://discourse.nodered.org/u/ChristophCaina)\
**Post date:** [24 February 2021 19:16 UTC](https://discourse.nodered.org/t/formating-input-signal-into-time-format/41544/3 "2021-02-24T19:16:32Z")

</div>

Thanks a lot, is working perfectly and exactly as expected 🙂  
Decimal values... I should have considered this :-/

Again, thanks a lot 🙂

---

<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:** [10 March 2021 19:16 UTC](https://discourse.nodered.org/t/formating-input-signal-into-time-format/41544/4 "2021-03-10T19:16:58Z")

</div>

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