Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Cerbion_ · Dec 08, 2014 at 07:13 PM · c#networktimesync

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Cerbion_ · Dec 09, 2014 at 02:32 AM 0
Share

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

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);
     }
 }
Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Cerbion_ · Dec 08, 2014 at 11:35 PM 0
Share

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

avatar image kdubnz · Dec 09, 2014 at 04:09 AM 1
Share

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.

avatar image MrTiger · Dec 09, 2014 at 08:08 AM 0
Share

thx Cerbi

avatar image Cerbion_ · Dec 12, 2014 at 02:59 PM 0
Share

kdub if you write that as an actual answer, I'll gladly upvote and close this thread ;)

avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

27 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges