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?
You 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());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.