Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript convert seconds to a date object

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.

like image 398
jhanifen Avatar asked Jan 06 '11 04:01

jhanifen


People also ask

How do I convert second to date?

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).

How do you convert seconds to HH mm SS format in Excel?

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.

How do I convert dates to seconds in bash?

Thanks it's works, i do start=$(date -d"$DateStart" +%s) and end=$(date -d"$DateEnd" +%s) and after time=$(end-start).

How do you convert seconds to HH mm SS in Python?

strftime('%H:%M:%S', time. gmtime(864001)) return a nasty surprise.


1 Answers

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.

like image 126
UVM Avatar answered Sep 21 '22 21:09

UVM