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
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#