I have a workflow node that grabs some info via an http api and it returns a time stamp in this format: “1/2/2019 5:52:29 PM”
How do easiest convert this into a timestamp that can be used in Losant?
A function node?
I have a workflow node that grabs some info via an http api and it returns a time stamp in this format: “1/2/2019 5:52:29 PM”
How do easiest convert this into a timestamp that can be used in Losant?
A function node?
Since both “1” and “2” could be both days and month, can you provide the format? Is it month/day/year or day/month/year?
I would guess month/day/year due to the actual date, but never know
it is month/day/year
I would recommend a Function Node. The JavaScript Date object can parse that string if you add the timezone to it.
So I’d recommend a function similar to below:
var date = payload.data.myDateString;
date += " GMT-05:00"; // Change this to match the timezone of the incoming date or leave it off if it's already GMT.
date = new Date(date); // parse the string
payload.data.myDateOffset = date.getTime(); // Converts to milliseconds since epoch, which Losant understands.