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?
You can take a look at date.js
http://www.datejs.com/
This alerts a date string set to today’s date, but with the time in datestr.
NOTE For this to work, I needed to zero-pad the seconds.
EDIT
The link for date.js format specifiers is a bit buried, so here’s that link if you need it:
http://code.google.com/p/datejs/wiki/FormatSpecifiers