Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
31
rated 0 times [  32] [ 1]  / answers: 1 / hits: 68185  / 13 Years ago, tue, february 28, 2012, 12:00:00

I have a unix timestamp, e.g., 1313564400000.00. How do I convert it into Date object and get month/year/day accordingly? The following won't work:



function getdhm(timestamp) {
var date = Date.parse(timestamp);
var month = date.getMonth();
var day = date.getDay();
var year = date.getYear();

var formattedTime = month + '/' + day + '/' + year;
return formattedTime;

}

More From » timestamp

 Answers
26
var date = new Date(1313564400000);
var month = date.getMonth();


etc.



This will be in the user's browser's local time.


[#87171] Sunday, February 26, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rayvenc

Total Points: 666
Total Questions: 125
Total Answers: 99

Location: Northern Ireland
Member since Mon, Nov 14, 2022
2 Years ago
;