Last active
August 24, 2018 07:07
-
-
Save hero9/1571748d2929bb76eb74214a9fa5990f to your computer and use it in GitHub Desktop.
This file contains 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
formatDays = function (d) { | |
var days = Math.floor(d / 86400), | |
hours = Math.floor((d - (days * 86400)) / 3600), | |
minutes = Math.floor((d - (days * 86400) - (hours * 3600)) / 60), | |
seconds = d - (days * 86400) - (hours * 3600) - (minutes * 60); | |
var output = ''; | |
if (seconds) { | |
output = seconds + 's'; | |
} | |
if (minutes) { | |
output = minutes + 'm ' + output; | |
} | |
if (hours) { | |
output = hours + 'h ' + output; | |
} | |
if (days) { | |
output = days + 'd ' + output; | |
} | |
return output; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment