--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/f444ffc7-3c56-4c58-a7b2-403a2919ddf3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Iain,with a Function node you can create a Date object from that timestamp, and then use one of methods available on that object to get a human-readable date. For example:var date = new Date(msg.payload.daily.data[0].time);msg.payload = date.toUTCString();return msg;Here's a list of the available methods on Date objects: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Datemoment.js provides more flexibility in the format it generates, but you can go a long with with the built-in Date object.Nick
On 22 May 2017 at 10:12, Iain MacMillan <macmill...@gmail.com> wrote:
I am trying to convert an EPOCH timestamp into its human readable format (string or object).I am calling the object "time" from Darkskys API {payload: msg.payload.daily.data[0].time}; and would like a function to return that value in a format that is not epoch so I can display it.I am fine with doing the conversation to different format strings/objects with day/month/time etc.My problem is getting the date stamp for that time, not time "now".Have tried the various momentjs nodes, but they don't seem to be for this.All the examples I see lead me down the path of creating a "date now". Whereas what I want is more a conversion.I see that node-red debug lets you click on the value and see it in the debug in human readable format, but it defaults to the long number.The annoying thing is that I know the answer is here somewhere as I had it working from an example from this forum a few weeks back. And even got it working momentarily at some point this weekend.Thanks
--
http://nodered.org
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/c33ce4e5-66d5-4272-b91b-673704063c33%40googlegroups.com.
[{"id":"ce06a058.827b4","type":"moment","z":"106ba95c.ff91e7","name":"UTC-4","topic":"UTC-4","input":"payload","inputType":"msg","inTz":"UTC-4","adjAmount":0,"adjType":"days","adjDir":"add","format":"ddd Do MMM YYYY HH:mm","locale":"en_GB","output":"","outputType":"msg","outTz":"UTC-4","x":410,"y":2380,"wires":[["676487bc.944dc8"]]},{"id":"daf66c4.a26919","type":"inject","z":"106ba95c.ff91e7","name":"2017-05-28T21:00:00-04:00","topic":"","payload":"2017-05-28T21:00:00-04:00","payloadType":"str","repeat":"","crontab":"","once":false,"x":160,"y":2380,"wires":[["ce06a058.827b4","16d02d70.722663","df86678e.f6f1d8"]]},{"id":"676487bc.944dc8","type":"debug","z":"106ba95c.ff91e7","name":"","active":true,"console":"false","complete":"false","x":730,"y":2380,"wires":[]},{"id":"16d02d70.722663","type":"moment","z":"106ba95c.ff91e7","name":"UTC","topic":"UTC","input":"payload","inputType":"msg","inTz":"UTC-4","adjAmount":0,"adjType":"days","adjDir":"add","format":"ddd Do MMM YYYY HH:mm","locale":"en_GB","output":"","outputType":"msg","outTz":"UTC","x":410,"y":2420,"wires":[["676487bc.944dc8"]]},{"id":"df86678e.f6f1d8","type":"moment","z":"106ba95c.ff91e7","name":"UTC+10","topic":"UTC+10","input":"payload","inputType":"msg","inTz":"UTC-4","adjAmount":0,"adjType":"days","adjDir":"add","format":"ddd Do MMM YYYY HH:mm","locale":"en_GB","output":"","outputType":"msg","outTz":"UTC+10","x":420,"y":2460,"wires":[["676487bc.944dc8"]]},{"id":"f5741865.49d2c8","type":"inject","z":"106ba95c.ff91e7","name":"2017-05-28T21:00:00-04:00","topic":"","payload":"2017-05-28T21:00:00","payloadType":"str","repeat":"","crontab":"","once":false,"x":160,"y":2460,"wires":[["df86678e.f6f1d8","16d02d70.722663","ce06a058.827b4"]]}]
Urm no, because your input date is actually on the 29th UTCSo 21:00 on 28th in timezone UTC-4 is 01:00 on the 29th in UTC and 11:00 on the 29th in UTC+10My node SHOULD(!) do that perfectly well. Unfortunately, it seems to have a couple of bugs as you can see from the following flow :(
...
The node seems easy enough to use