# Msg object is not readable info

**URL:** <https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180>\
**Category:** General\
**Created:** [26 October 2019 22:02 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180 "2019-10-26T22:02:12Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hein](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@Hein](https://discourse.nodered.org/u/Hein)\
**Post date:** [26 October 2019 22:02 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/1 "2019-10-26T22:02:12Z")

</div>

Good day people of Node-Red

I have a serious problem with the info I`m reading of my weather API.

I get info into a function node that exports the sunset and sunrise times, now the problem is that it gives me the info in a weird way.

EG. Object:

sunrise: 1572060152

sunset: 1572106754

now if I click on the number it changes to a HEX. And if I click on it again it changes to something else, not sure what u call it but it looks like this "2019-10-26T03:22:32.000Z" And then if I click it again I get the info that I require **10/26/2019, 5:32:32 AM [UTC+2]**

I need to get the time extracted from that info but it doesn't matter what I try the outcome is always the 10 digit number...

Please help.

---

<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:** [26 October 2019 22:53 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/2 "2019-10-26T22:53:19Z")

</div>

That looks like [UNIX (or Epoch) time](https://en.wikipedia.org/wiki/Unix_time). When you click on it in the debug panel, NR changes it to a more readable format for you (those developers are pretty cool!)

You could feed that into the moment node (node-red-contrib-moment and it willl handle it for you.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [27 October 2019 08:24 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/3 "2019-10-27T08:24:29Z")

</div>

alternative as you are already using a function node you can multiply the unixtimestamp by 1000 to get a javascript timestamp and then use the javascript date commands

---

<div class="post-metadata">

**Author:** ![Hein](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@Hein](https://discourse.nodered.org/u/Hein)\
**Post date:** [27 October 2019 14:33 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/4 "2019-10-27T14:33:38Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/3940a36b3c29cce3ae6e4fe40f7badcb37b4b187.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/69552b7b6b014531ffe019f75080d32ef8f31a90.png)

As you can see I tried the moment's node... And it changed it to 1970???

---

<div class="post-metadata">

**Author:** ![Hein](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@Hein](https://discourse.nodered.org/u/Hein)\
**Post date:** [27 October 2019 14:36 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/5 "2019-10-27T14:36:44Z")

</div>

What code do i insert in the funtion node.  
I tried moments(string).

Ive been on this for 2 days?? No Luck

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [27 October 2019 15:16 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/6 "2019-10-27T15:16:57Z")

</div>

Here are the docs for the standard JavaScript Date object:

> **[Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)**
>
> Creates a JavaScript Date instance that represents a single moment in time in a platform-independent format.

It provides a number of functions to generate a human readable string. For example:

```auto
msg.sunrise = (new Date(msg.sunrise)).toISOString();

```

---

<div class="post-metadata">

**Author:** ![Hein](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@Hein](https://discourse.nodered.org/u/Hein)\
**Post date:** [27 October 2019 17:50 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/7 "2019-10-27T17:50:31Z")

</div>

Hi knolleary,

I tried your method but the dates are returned in the 1970`s...  
Here is my function node code:

```auto
srise = (new Date(msg.payload.sunrise)).toISOString();
sset = (new Date(msg.payload.sunset)).toISOString();

return {sunrise : srise, sunset : sset};

```

My payload looks like this:

```auto
10/27/2019, 7:47:48 PMnode: ea77ae2.594fe5
msg : Object
object
sunrise: "1970-01-19T04:43:52.921Z"
sunset: "1970-01-19T04:44:39.716Z"
_msgid: "81f13ea7.e6e22"

```

Thank you for the help so far...

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [27 October 2019 17:53 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/8 "2019-10-27T17:53:20Z")

</div>

Try multiplying by 1000

```auto
srise = (new Date(msg.payload.sunrise * 1000)).toISOString();

```

etc

---

<div class="post-metadata">

**Author:** ![Hein](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@Hein](https://discourse.nodered.org/u/Hein)\
**Post date:** [27 October 2019 17:55 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/9 "2019-10-27T17:55:56Z")

</div>

Hi dceejay,

Ok that fixed the date  
Here is my function node code:

```auto
srise = (new Date(msg.payload.sunrise * 1000)).toISOString();
sset = (new Date(msg.payload.sunset * 1000)).toISOString();

return {sunrise : srise, sunset : sset};

```

Here is the payload:

```auto
10/27/2019, 7:56:54 PMnode: ea77ae2.594fe5
msg : Object
object
sunrise: "2019-10-28T03:22:01.000Z"
sunset: "2019-10-28T16:21:56.000Z"
_msgid: "2589830c.3f607c"

```

how to fix the time??

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [27 October 2019 18:01 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/10 "2019-10-27T18:01:06Z")

</div>

If you mean that you want it in your local timezone, the answer is in the page that @knolleary linked to

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [27 October 2019 18:54 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/11 "2019-10-27T18:54:05Z")

</div>

> [@Hein](#):
>
> how to fix the time??

What do you mean by 'fix'…? What do you want it to look like?

---

<div class="post-metadata">

**Author:** ![Hein](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@Hein](https://discourse.nodered.org/u/Hein)\
**Post date:** [27 October 2019 19:19 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/12 "2019-10-27T19:19:35Z")

</div>

Hi knolleary,

I managed to fix the time somewhat....  
My time now looks like this.:

```auto
10/27/2019, 9:06:47 PMnode: ea77ae2.594fe5
msg : Object
object
sunrisetime: "Monday, October 28, 2019, 3:22:01 AM"
sunsettime: "Monday, October 28, 2019, 4:21:56 PM"
_msgid: "cf9c2bc9.a671c8"

```

But it is in the wrong timezone...  
it is in UTC if I read correctly on the page that you said i must visit.  
But I can't seem to set the timezone to UTC+2.

Here is my Function Node so far...

```auto
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };

srisetime = (new Date(msg.payload.sunrise * 1000)).toLocaleTimeString('en-ZA');
ssettime = (new Date(msg.payload.sunset * 1000)).toLocaleTimeString('en-ZA');

return {sunrisetime : srisetime, sunsettime : ssettime};

```

I`m trying to find a solution... But on that page it`s like finding a needle in a bunch of needles. 😃

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [27 October 2019 19:28 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/13 "2019-10-27T19:28:34Z")

</div>

look at the “ toLocale” parts of that page

---

<div class="post-metadata">

**Author:** ![Hein](https://avatars.discourse-cdn.com/v4/letter/h/b2d939/32.png) [@Hein](https://discourse.nodered.org/u/Hein)\
**Post date:** [27 October 2019 19:39 UTC](https://discourse.nodered.org/t/msg-object-is-not-readable-info/17180/14 "2019-10-27T19:39:48Z")

</div>

Thank you ukmoose...  
It worked 100% almost 3 days struggling with this.  
Thanks for pushing me to read the documentation.

Here is the Final Function Node:

```auto
srisetime = ((new Date(msg.payload.sunrise * 1000)).toLocaleString('en-ZA', { timeZone: 'Africa/Johannesburg' }));
ssettime = ((new Date(msg.payload.sunset * 1000)).toLocaleString('en-ZA', { timeZone: 'Africa/Johannesburg' }));

return {sunrisetime : srisetime, sunsettime : ssettime};

```

And here is the end Result:

```auto
10/27/2019, 9:37:52 PMnode: ea77ae2.594fe5
msg : Object
object
sunrisetime: "10/28/2019, 5:22:01 AM"
sunsettime: "10/28/2019, 6:21:56 PM"
_msgid: "67922e46.308ef"

```

Once again thank you!!
