Home:ALL Converter>convert unix time to date object

convert unix time to date object

Ask Time:2012-11-16T01:18:14         Author:

Json Formatter

I have a unix time and need to get a Date object from it. This code just transform the timestamp to human readable way:

var date = new Date(unix_timestamp*1000);
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var formattedTime = hours + ':' + minutes + ':' + seconds;

As a result I get 13:44:6, for instance but how I can create a Date object with time and date from it?

Author:,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/13402801/convert-unix-time-to-date-object
yy