- Home /
C# get universal time
Hello guys,
I am working on an MMO that will feature different timezones that are related to realworld times.. now the thing is, I don't just want to use DateTime.Now or anything, because that would mean the players have control over their clients ingame time, so I'd rather want toknow if there is any efficient way of getting time from a static timezone (let's say UTC) and convert that in my scripts to my needs so that every user see's the sunset at the exact same moment? Maybe with syncing everything up every now and then (maybe each hour).
Any suggestions and constructive discussions are welcome, thanks!
~Cerbi
I think probably the best solution would be to create a php script that echo's the servers time.. and sync that every few $$anonymous$$utes, but I hope there's a better solution for that :I
Answer by MrTiger · Dec 08, 2014 at 07:59 PM
i believe this is the one you are looking for
using UnityEngine;
using System.Collections;
using System;
public class UTC: MonoBehaviour
{
void Update()
{
print (DateTime.UtcNow);
}
}
doesn't UTCNow return my local time and converts it into UTC timezone? I am actually not sure..
EDIT: I was right, I just checked the $$anonymous$$SDN: "Gets a DateTime object that is set to the current date and time on this computer, expressed as the Coordinated Universal Time (UTC)."
So it doesn't really help me out too much, since I don't want players to abuse the system by just changing their time on their local machines
Perhaps try something like this :
http://nickstips.wordpress.com/2010/02/12/c-get-nist-internet-time/
Downside will be that the user $$anonymous$$UST have an internet connection available for the time check.
kdub if you write that as an actual answer, I'll gladly upvote and close this thread ;)
Answer by KrlinM · Oct 20, 2017 at 10:28 PM
For others with this same problem.
I found useful this:
http://saadkhawaja.com/get-time-server/
in connection with this:
https://www.youtube.com/watch?v=Yoh6owRXCXA
Best solution is as always the easiest
Your answer
Follow this Question
Related Questions
AudioClip sync across a network: help needed! 0 Answers
Syncing times 0 Answers
remove spawned object from my networkView when timeScale = 0 0 Answers
Emit particles for all clients 1 Answer
Is Network.time Syncronized with other peers on the network 0 Answers