Unity & Trusted Server Time
In mobile games, users often change their device clock to speed up wait timers or get daily rewards early. By checking our API, you can enforce server-side time validation without setting up your own backend infrastructure.
CSHARP
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
public class TimeChecker : MonoBehaviour {
void Start() {
StartCoroutine(GetTrustedTime());
}
IEnumerator GetTrustedTime() {
string url = "https://time.now/developer/api/timezone/UTC";
using (UnityWebRequest webRequest = UnityWebRequest.Get(url)) {
yield return webRequest.SendWebRequest();
if (webRequest.result == UnityWebRequest.Result.Success) {
// Simple parsing or use JsonUtility
Debug.Log("Server Time JSON: " + webRequest.downloadHandler.text);
} else {
Debug.LogError("Error: " + webRequest.error);
}
}
}
}
Why use Time.Now for Game Dev?
- Prevents 'Time Skipping' cheats
- No backend required
- Works on iOS/Android/PC builds