Convert a Unix timestamp to time in Javascript
/**
* Convert a Unix timestamp to time in Javascript
* See http://stackoverflow.com/questions/847185/convert-a-unix-timestamp-to-time-in-javascript
* @param int unix_tm Unix timestamp in seconds from for instance PHP
* @return date timestamp in milliseconds
*/
function dateFromUnixTimeStamp(unix_tm) {
return new Date(unix_tm*1000);
}
Courtesy of Aron Rotteveel on Stackoverflow
http://stackoverflow.com/users/11568/aron-rotteveel
Thanks @thajeztah
Written by pimschaaf
Related protips
1 Response
I'd remove the interim dt variable, probably no reason to have it. Also, a more descriptive name wouldn't hurt, e.g. dateFromUnixTimeStamp()
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#