Teshan N.
Teshan N.

Reputation: 2535

Convert INT to TIME using JS

I have converted a feed's published date "pubDate" to integer using JS. Here is the code I used for it.

function timetoint(date){
    var date = new Date(date);
    return Math.round(date.getTime()/1000);
}

Now I need to convert the result of the above function back to a time format. How can I do it?

Upvotes: 0

Views: 4936

Answers (1)

Denys Séguret
Denys Séguret

Reputation: 382304

Use the Date constructor :

 var date = new Date(time*1000);

Upvotes: 4

Related Questions