# How to extract time from "node-red-contrib-sunpos"?

**URL:** <https://discourse.nodered.org/t/how-to-extract-time-from-node-red-contrib-sunpos/10253>\
**Category:** General\
**Created:** [16 April 2019 15:09 UTC](https://discourse.nodered.org/t/how-to-extract-time-from-node-red-contrib-sunpos/10253 "2019-04-16T15:09:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [16 April 2019 15:09 UTC](https://discourse.nodered.org/t/how-to-extract-time-from-node-red-contrib-sunpos/10253/1 "2019-04-16T15:09:12Z")

</div>

Hi all,  
I installed "node-red-contrib-sunpos" to display the position of the sun in real time. This function works.  
This node is used to display the sunset time "msg.payload.endTime" as can be seen on the debug (N°1): **in seconds.**  
 ![InkedendTime_LI](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/59fb26ad64c6b1f3737fcba5e1c6622dd86ebf33.jpeg)  
If I click on the Debug payload (N°2): endTime is displayed **in Hexa**  
If I still click (N°3) I display in **world time (?)**  
If I click again (N°4) I display in local time " **UTC + 2"** =\> **It is this last value that I wish to recover from this Node.**

**Note** : we see this value under the Node. (Status node)

Do you know how I can recover this value directly in UTC + 2?

Thank you

---

<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:** [16 April 2019 22:39 UTC](https://discourse.nodered.org/t/how-to-extract-time-from-node-red-contrib-sunpos/10253/2 "2019-04-16T22:39:09Z")

</div>

Search "JavaScript epoch to date and time" (or similar)

Alternatively, install the "moment" node to do format conversions.

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [17 April 2019 09:48 UTC](https://discourse.nodered.org/t/how-to-extract-time-from-node-red-contrib-sunpos/10253/3 "2019-04-17T09:48:30Z")

</div>

Thanks for the answer, I'll watch this.  
It's still annoying to have recourse to an additional node, whereas the "suncalc" node already has this function of epoch =\> date & time, integrated. I do not like to change the already existing flow, but I will try ... to pass the time lol

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 April 2019 10:23 UTC](https://discourse.nodered.org/t/how-to-extract-time-from-node-red-contrib-sunpos/10253/4 "2019-04-17T10:23:30Z")

</div>

> [@SuperNinja](#):
>
> It's still annoying to have recourse to an additional node, whereas the "suncalc" node already has this function of epoch =\> date & time, integrated.

Why not ask the author to include that in the returned data or even better fix the code and do a pull request on it?

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [17 April 2019 11:03 UTC](https://discourse.nodered.org/t/how-to-extract-time-from-node-red-contrib-sunpos/10253/5 "2019-04-17T11:03:51Z")

</div>

you're right, I'll do all this 😉

---

<div class="post-metadata">

**Author:** ![SuperNinja](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superninja/32/5761_2.png) [@SuperNinja](https://discourse.nodered.org/u/SuperNinja)\
**Post date:** [17 April 2019 14:57 UTC](https://discourse.nodered.org/t/how-to-extract-time-from-node-red-contrib-sunpos/10253/6 "2019-04-17T14:57:34Z")

</div>

And here it is done thanks to @alisdairjsmyth🤩

```auto
var d = new Date (msg.payload.endTime);
var n = d.toLocaleTimeString ();
msg.endLocaleTime = n;

// **********displays the status of the Node**********
node.status ({text: n});

return msg;

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/5197ffa4e022a8a3eb8226e520f293fa6d969805.png)
