Reputation: 860
In short this function returns a time which is then used to query a JSON file, it seems for the query to work my date needs to be in string format, It will not work if I pass the result of recent_time()
into the query.
function recent_time(process) {
date_array = []
for (var object in process) {
var processtime = new Date(process[object]);
date_array.push(processtime)
}
max_date = new Date(Math.max.apply(null, date_array));
return max_date
}
Currently the value returned is in the format 2019-05-22T11:01:18.000Z
I need it to read as this (for my json query purpose):
"2019-05-22T11:01:18.000Z"
- note it is in string format
I have tried return max_date.toString()
However this returns the format
Wed May 22 2019 11:01:18 GMT+0100 (British Summer Time)
Any help is appreciated
Upvotes: 0
Views: 37
Reputation: 14423
You are probably looking for the .toISOString()
method.
Upvotes: 1