Jump to content

not calculating day time different


Recommended Posts

local currentTime = getRealTime()
local second = 59 -- example data
local timeleft = 60-(currentTime.second-second)
outputChatBox("Time left : "..math.floor((timeleft/60)/24)..":"..(60-math.floor(timeleft/60))..":"..timeleft)
output : 0:60:70
must be : 23:59:59


cannot be calculated correctly. I think the linux server is also a problem.

I couldn't solve the problem so i need help.


Link to comment
  • Moderators
16 minutes ago, freudo said:

I'm trying to count down from 24 to 1.

Use timestamp:

local currentTime = getRealTime().timestamp


Since the index seconds is only from 0 > 59.


Edited by IIYAMA
Link to comment
currentTime = 1604249518
dataTime = 1604249510
timeleft = 60-(currentTime-dataTime)
hours = math.floor((timeleft/60)/24)
minutes = (60-math.floor(timeleft/60))
print("Time left : "..tostring(hours)..":"..minutes..":"..timeleft)

output : Time left : 0:60:8


Thanks guys, I solved

This works.

currentTime = 1604230289602
dataTime = 1603230289602
print(currentTime - dataTime)
timeleft = math.floor((currentTime-dataTime)/1000)
minutes = math.floor(timeleft/60)
hours = math.floor(minutes/60)
days = math.floor(hours/24)
minutes = minutes%60
hours = hours%24

print("Time left : "..tostring(days).."gün "..tostring(hours).." saat "..tostring(minutes).." dakika")


Edited by freudo
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...