Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
77
rated 0 times [  79] [ 2]  / answers: 1 / hits: 43847  / 10 Years ago, wed, june 11, 2014, 12:00:00

Timestamp:



1395660658


Code:



//timestamp conversion
exports.getCurrentTimeFromStamp = function(timestamp) {
var d = new Date(timestamp);
timeStampCon = d.getDate() + '/' + (d.getMonth()) + '/' + d.getFullYear() + + d.getHours() + ':' + d.getMinutes();

return timeStampCon;
};


This converts the time stamp properly in terms of time format, but the date is always:



17/0/1970


Why - cheers?


More From » javascript

 Answers
8

You have to multiply by 1000 as JavaScript counts in milliseconds since epoch (which is 01/01/1970), not seconds :



var d = new Date(timestamp*1000);


Reference


[#70614] Tuesday, June 10, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dylondarrianb

Total Points: 48
Total Questions: 109
Total Answers: 104

Location: Zambia
Member since Thu, Jun 25, 2020
4 Years ago
;