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.


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.


You can pass unix timestamp milliseconds as an argument to the Date constructor:

var secs = 30;
new Date(secs * 1000);

Outputs:

Date 1970-01-01T00:00:30.000Z