05 - Protecting against device clock cheating (Pro)
Goal: You will learn how to stop players from skipping timers, trials, or daily rewards by changing the date and time of their device, and how to use a safer clock with ProtectedTime.
This guide needs the Pro version.
The problem
Many games trust the clock of the device for energy refills, daily rewards, event dates, or trials. That clock belongs to the player. A cheater opens the date and time settings, jumps hours or days ahead, and comes back to the game. The cooldown is over, the trial never ends, or tomorrow's reward is ready now.
This is not a speed hack. A speed hack makes the running game faster. Here the player changes the date and time of the device itself.
The solution
Use Anti-Cheat ProtectedTime.UtcNow in place of DateTime.UtcNow. It gives you the time in UTC, the world time without time zones. Two parts then do the work:
- Two device time monitors watch the device clock. One compares it with a clock the player cannot edit. The other compares it with a time from the internet.
- The Device Time Cheating Detector decides if a difference means the clock was moved, and reports it.
Step 1: Know what depends on the device clock
Anything that asks "what time is it in the real world?" is at risk when it uses DateTime.Now or DateTime.UtcNow:
- Energy and stamina timers: Jump the clock forward to refill at once.
- Daily and weekly rewards: Claim the same reward many times by moving the date.
- Trials and subscriptions: Move the clock back so a trial never ends.
- Timed events and shops: Unlock future content early by setting the date ahead.
Protect the places where the date gives an advantage. A timestamp in a log does not need it.
Step 2: Replace DateTime.UtcNow with ProtectedTime.UtcNow
A simple energy timer before:
using System;
using UnityEngine;
public class EnergyTimer : MonoBehaviour
{
private DateTime nextRefillUtc;
public bool CanRefill()
{
// The device clock: the player can change it.
return DateTime.UtcNow >= nextRefillUtc;
}
}
And after:
using System;
using GUPS.AntiCheat.Protected.Time;
using UnityEngine;
public class EnergyTimer : MonoBehaviour
{
private DateTime nextRefillUtc;
public bool CanRefill()
{
// The protected clock.
return ProtectedTime.UtcNow >= nextRefillUtc;
}
}
Step 3: Make sure the detector is there
ProtectedTime.UtcNow needs the Device Time Cheating Detector and its two monitors.
The predefined Anti-Cheat-Monitor prefab already includes them. If you use it, you have nothing to do here.
If you use your own monitor prefab, add the Device Time Cheating Detector prefab to it. It holds the detector and both monitors together. Drag it onto the monitor in your prefab so it becomes a child.

Image 1: The detector prefabs in Assets/GUPS/AntiCheat/Resources/Prefabs/Detectors.
Note
The monitors and the detector must be on the same GameObject. The prefab already sets this up.
Step 4: Set up the detector and the internet time
Select the Device Time Cheating Detector. The Inspector shows the detector and the two monitors.

Image 2: The Device Time Cheating Detector in the Inspector.
On the detector:
- Tolerance: How many seconds the device clock may be off before it is reported. The default is 25. The minimum is 1.
- Is Active: Turns the detector on or off.
- Possibility Of False Positive: How likely a find is a false alarm. The default is 0.25, because a drifting clock or a long sleep can look like a moved clock.
- Threat Rating: How much one find adds to the threat score of the Anti-Cheat Monitor. The default is 400.
- On Cheating Detection Event: Your own reactions. Assign a method here. You need no code for that.
On the Device Time Event Monitor:
- Use Internet Time: On by default. The trusted time is read from a server, not from the device clock. Leave it on for the best protection. If a read fails, the last trusted time is kept.
- Server Address: The server that gives the time. The default is
https://cloudflare.com/cdn-cgi/trace. It works on every platform, including WebGL. - Server Certificate Hash: Optional. Use it only with a server you control. The device time monitors page explains it.
You can also ask the detector in code:
var detector = AntiCheatMonitor.Instance.GetDetector<DeviceTimeCheatingDetector>();
if (detector != null && detector.PossibleCheatingDetected)
{
// The device clock was moved.
}
This flag turns off again when the clock looks normal.
Step 5: Wait for the server time before a reward
The first read from the server takes a moment after the game starts. Until it works, ProtectedTime.UtcNow uses the device clock.
For a reward that must only use the server time, wait until the detector says it is there:
var detector = AntiCheatMonitor.Instance.GetDetector<DeviceTimeCheatingDetector>();
if (detector != null && detector.IsServerTimeResolved)
{
// ProtectedTime.UtcNow now comes from the server.
}
Step 6: Try it
Open the demo scene Assets/GUPS/AntiCheat/Demos/Demo_DeviceTime/Scene.unity. It shows a calendar and a daily reward. Change the date in your operating system, once without and once with Anti-Cheat. The demo folder has its own ReadMe.
The result
With ProtectedTime.UtcNow in your timers and the Device Time Cheating Detector running:
- Energy, daily rewards, and trials no longer trust a clock the player can edit.
- Moving the device date forward or back is noticed and reported to the Anti-Cheat Monitor.
- With Use Internet Time on, the protected time comes from a server. It stays right even if the device clock was already wrong at the start.
Note
The predefined monitor prefab has no punisher. A find raises the threat score, but nothing more happens to the player until you react yourself or add a punisher.
Note
Protection inside the game makes cheating harder. For rewards with real value, such as purchases or ranked seasons, also check the timer on your own server when you can.
Settings reference: Protected Device Time, Device time monitors, and Device time detector.
Next steps
- Protecting against speedhacks helps if the cheat speeds the game up and does not change the date.
- Reacting to detected cheating and Punishing cheaters show what to do when a cheat is found.
Next guide: 06 - Protecting against auto clickers (Pro).
Back to the Guides overview.