• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

Bug with os.date() (1 Viewer)

Pastis444

Newcomer
Joined
Mar 20, 2022
Messages
2
Reaction score
0
So, I have this basic code, but everytime I execute it, it add 1 to the number of hour idk why.
Lua:
starttime = os.time()
times = true
while times do
    print(os.date('%X', os.time() - starttime))
    wait(0.1)
end
 

smi

Newcomer
Joined
Mar 25, 2022
Messages
1
Reaction score
1
os.date() returns local time according to your system locale. You are probably in timezone UTC+1 for hour to start with 1.

In function os.date() you can specify to use UTC by using prefix ! before your %X like this !%X. Try this:

Lua:
starttime = os.time()
while true do
    print(os.date('!%X', os.time() - starttime))
    wait(0.1)
end
 
Last edited:

Pastis444

Newcomer
Joined
Mar 20, 2022
Messages
2
Reaction score
0
os.date() returns local time according to your system locale. You are probably in timezone UTC+1 for hour to start with 1.

In function os.date() you can specify to use UTC by using prefix ! before your %X like this !%X. Try this:

Lua:
starttime = os.time()
while true do
    print(os.date('!%X', os.time() - starttime))
    wait(0.1)
end
Thank you so much ! It actually fixed my problem. I love you <3
 
Top