For some reason I can't find the answer to how to format a string from new Date().getTime().
When I run this string, I get a sequence of numbers such as 1395430135200.
How do I format this back into a readable date with time zone?
For some reason I can't find the answer to how to format a string from new Date().getTime().
When I run this string, I get a sequence of numbers such as 1395430135200.
How do I format this back into a readable date with time zone?
Share Improve this question asked Mar 21, 2014 at 22:31 AllenAllen 3,77110 gold badges42 silver badges60 bronze badges 1- 2 Have you really tried to find an answer? – Teemu Commented Mar 21, 2014 at 22:35
2 Answers
Reset to default 5You need to pass the UNIX time as a parameter to a new date object and can then use .toString()
to get a readable interpretation. Like this:
new Date(1395430135200).toString()
// "Fri Mar 21 2014 20:28:55 GMT+0100 (W. Europe Standard Time)"
Why not just use new Date()?
var now = new Date();
console.log(now.toLocaleDateString());
console.log(now.toLocaleTimeString());