How do i fix this?

Hello, testing a os.date() system when this happened:
Studio
robloxapp-20240223-2125223.wmv (169.5 KB)
Roblox
robloxapp-20240223-2126123.wmv (83.5 KB)

This is my Script (not a LocalScript or ModuleScript):

while true do
	script.Parent.Text = os.date()
	wait(1)
	script.Parent.Text = os.date()
end

Script Location: StarterGui>ScreenGui>Frame>TextLabel>Script.

Thank you!
@MasterAtTheWings

1 Like

What’s the issue, can you explain please?

Why is there a server script in starterGUI

2 Likes

What exactly is your issue because when I tried replicating any bugs nothing appeared, the script works as intended.

while true do
    script.Parent.Text = os.date()
    task.wait(1)
end

There’s a bug when i use Studio it’s normal like my date/time in my OS (UTC-4). But in Roblox App, It shows UTC+0

Game that occur the issue

@MasterAtTheWings

The issue didn’t got fixed by your script, it’s a localscript? or a module?

Se você chamar a função os.date sem nenhum parâmetro, ela chama automaticamente a função os.time, que retorna o horário em tempo UTC, como você mesmo percebeu.

Segundo a API (interface de programação da aplicação), é necessário você chamar os.date com o argumento "*t" para receber o horário local. Você (provavelmente, já que eu não sei) tem que rodar isso num LocalScript, para que ele retorne um horário específico para cada jogador.

1 Like

that’s not a bug, because in the document of os.date here. It states os.date " Returns how many seconds have passed since the Unix epoch (1 January 1970, 00:00:00), under current UTC time. If provided a table formatted similarly to that returned by os.date(), it will return the number of seconds since that time instead." instead of UTC-4 due it to using the current server time.

1 Like

In Roblox Studio, your computer handles the server you’re playtesting in. So when you use os.date(), it uses your device as the Local Time. If you use the Roblox App however, it will return the Local Time of the server’s location. So if the server were to be in the US, it would return a date and time in that location.

Using a Local Script to get os.date() only uses your device.

a unica coisa q tirou o bug do seu post foi, colocar em um localscript!
@MasterAtTheWings

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.