what do you mean???
You can use some math with the Epoch time and achieve the required result.
Do you have any suggestions to use this?
Please consider searching devforum once before creating a post.
Hey, but I don’t want the time different for each user, I want it all same as one set Time by the developer.
It’ll be mapped to the real world time + whatever offset you set.
Oh alright, do you have any suggestions to connect that with the game time ?
using DateTime, you can get the UTC time or the Local Time of a user. UTC is the same no matter what time zone the user is in. The Loocal Time will change based on the user’s time zone. You can create a variable GameTime to be equal to the UTC and have it update with the UTC + whatever offset you would like.
if you want you could use tick()
and when a player joins, add a value to them that saves the tick()
value. Then just minus the current tick()
from their saved value and convert it to time.
(this starts a clock from when they first joined)
This sounds amazing! So would I just set the UTC time as the game time or do I need to like convert it to Roblox’s games time!
UTC would be the real world time. From what I know, you can’t change the server time or what roblox has its os.clock() or tick() as, but you could create your own game time using a variable and a script to manage it, then have any time related function in your game go off of that time. if you make the time related to the UTC is some way tho, it will be able to update and will be sync’d across all servers
So would you recommend me to try this method or do you think doing this would be hard?
It wouldn’t be hard at all. You could add an attribute to Workspace and call it “Game Time” and then in a script update Game Time to be UTC. Then you can add wtv offsets you want to customize it to be however you want. Then in that script you can have all the functions you want to have around the Time be. That’s how I would think to do it at least.
Oh, could you give me some help with creating the script for it?
You can use os.time() and calculate the diference from your time! Roblox uses UTC timezone, i’m in GMT-3 that is 3 hours of diference from UTC so, basicaly what i do is
os.time() - ( 3 * 60 * 60 ) -- returns my exact timezone
i hope that this helped!
I find it so weird how this is a phenomenon of someone asking for something shortly after a topic of the same matter is posted.
He asked that he wanted everyone to have the same time, not local.
If you put it in a server script, I believe it will sync the time to the server’s time, which is UTC.
DateTime.now():ToUniversalTime()
works well.
If it were needed that it was the same time for everyone, it could be easily modified.