How can I convert seconds into a datetime object in javascript.
Examples:
1.3308313703571
1.6324722385401
This is from a series of points and when they occurred. I understand 1.23323 more then seconds, but I can not change the value, being pulled from an api.
setTime(secs * 1000)" gives me the correct result. This solution gets affected by system timezone, new Date(1970, 0, 1). toISOString() outputs 1969-12-31T21:00:00.000Z (GMT+0300 in my case).
As with Excel, the first step to converting elapsed second to time is to divide the value by 86400. To format the cells for mm:ss, select Format > Number > More Formats > More date and time formats from the Menu.
Thanks it's works, i do start=$(date -d"$DateStart" +%s) and end=$(date -d"$DateEnd" +%s) and after time=$(end-start).
strftime('%H:%M:%S', time. gmtime(864001)) return a nasty surprise.
You can try like this:
function toDateTime(secs) { var t = new Date(1970, 0, 1); // Epoch t.setSeconds(secs); return t; }
Info on epoch date.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With