JavaScript SDK — Server Time

Server Time — mp.time

get
await mp.time.get({ utc?, format? })

Returns the authoritative server time — use for synchronized countdowns, expiry checks and clock-skew measurement instead of trusting the client clock. The CLI's mp bench times these calls for latency measurement.

Authoritative server time

Get returns the authoritative server clock — the one timestamp every player agrees on. Use it for shared countdowns, round-end deadlines, cooldown and expiry checks: anything a client clock can cheat or drift on. A UTC option keeps the value timezone-correct wherever the player is.

The offset variant exists for skew math: measure the difference once at session start, then offset local timestamps and you only pay the round trip once. The same call doubles as a lightweight latency probe — the CLI's bench command times it for exactly that reason.

  • Sync shared timers (round ends, vote deadlines) against server time so every client hits zero together.
  • Never trust the device clock for game rules — players can set it forward to skip cooldowns.
  • Measure skew once and reuse the offset — calling per check adds latency without extra accuracy.
  • Every call returns a Promise — await inside async functions. In browsers requests run over fetch with CORS; on Node.js 22.12+ the identical API uses the built-in fetch.