Created
August 20, 2014 21:11
-
-
Save nkint/24426093c5e29a62803a to your computer and use it in GitHub Desktop.
javascript: timestamp to human readable (hours, minutes, seconds)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.epochconverter.com | |
function TimeCounter(t) { | |
var days = parseInt(t / 86400); | |
t = t - (days * 86400); | |
var hours = parseInt(t / 3600); | |
t = t - (hours * 3600); | |
var minutes = parseInt(t / 60); | |
t = t - (minutes * 60); | |
var content = ""; | |
if (days) content += days + " days"; | |
if (hours || days) { | |
if (content) content += ", "; | |
content += hours + " hours"; | |
} | |
if (content) content += ", "; | |
content += minutes + " minutes and " + t + " seconds."; | |
return content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment