Answer the question
In order to leave comments, you need to log in
How to correctly translate timestamp into time?
There is a timestamp for example 1403774400000
Using the toGMTString() function, I translate it like this:
var myDate = new Date(1403774400000);
console.log(myDate.toGMTString()); //Thu, 26 Jun 2014 09:20:00 GMT
Answer the question
In order to leave comments, you need to log in
// создаете Date-объект с вашим timestamp
var date = new Date( unix_timestamp * 1000 );
// извлекаем часы
var hours = date.getHours();
// минуты
var minutes = date.getMinutes();
// секунды
var seconds = date.getSeconds();
// показываем в нужном формате: 11:17:23
var time = hours + ':' + minutes + ':' + seconds;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question