I am receiving a JSON object from a the DarkShy weather api, and I want to access the timestamp for each report for a Chart.JS chart where I will display the temperature over day, right now I am stuck in converting the timestamp into a HH:DD:SS format.
This is what I tried
// Displays the wrong time according to https://www.epochconverter.com/
var timeofDay = new Date(daily[i].time)
time.push( timeofDay.toTimeString().split(' ')[0] )
// Gets rid off the time, tho It get the date correctly
var timeofDay = new Date(parseFloat(daily[i].time) * 1000)
time.push( timeofDay )
// Returns the wrong date and time
time.push(new Date(daily[i]))
Here's how I loop through the JSON file
let time = []
let temperatureDaily = []
for(var i=0; i<daily.length; i++){
// Push the values into the arrays
var timeofDay = new Date(parseFloat(daily[i].time) * 1000)
time.push( timeofDay )
temperatureDaily.push( (parseFloat(daily[i].temperatureHigh) + parseFloat(daily[i].temperatureLow)) /2)
}
console.log(time);