Skip to content

Instantly share code, notes, and snippets.

@gabyfle
Last active May 7, 2019 18:49
Show Gist options
  • Save gabyfle/740e173d908066ea9b9cfa52d656a78e to your computer and use it in GitHub Desktop.
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
-- 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