Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
32
rated 0 times [  37] [ 5]  / answers: 1 / hits: 133014  / 14 Years ago, thu, january 6, 2011, 12:00:00

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.


More From » datetime

 Answers
12

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.


[#94356] Tuesday, January 4, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jadyngraysons

Total Points: 455
Total Questions: 109
Total Answers: 98

Location: Trinidad and Tobago
Member since Fri, May 8, 2020
4 Years ago
jadyngraysons questions
Thu, Apr 23, 20, 00:00, 4 Years ago
Sat, Jan 18, 20, 00:00, 4 Years ago
Tue, Dec 31, 19, 00:00, 4 Years ago
;