Last active
May 7, 2019 18:49
-
-
Save gabyfle/740e173d908066ea9b9cfa52d656a78e to your computer and use it in GitHub Desktop.
Gets number of days, hours, minutes and seconds from an amount of seconds
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
-- Number of seconds to convert | |
local seconds = 1850 | |
-- 1 day = 86400 s | |
-- 1 hour = 3600 s | |
-- 1 minute = 60 s | |
local days = math.floor(seconds / 86400) | |
local hours = math.floor((seconds - days * 86400) / 3600) | |
local minutes = math.floor((seconds - days * 86400 - hours * 3600) / 60) | |
seconds = math.floor(seconds - days * 86400 - hours * 3600 - minutes * 60) | |
print(days .. ' J ' .. hours .. ' H ' .. minutes .. ' MINS ' .. seconds .. ' S ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment