An accurate clock matters more than it seems. Authentication (Kerberos, TOTP 2FA, TLS certificates), API requests with timestamps (exchanges, payment providers), log correlation and trading all break or misbehave when the server’s time drifts. Windows uses the Windows Time service (W32Time) to sync with NTP servers. Here’s how to check and configure it.

Linux equivalent: NTP time sync with chrony.

Check the current status

w32tm /query /status
w32tm /query /source
w32tm /query /configuration
w32tm /stripchart /computer:time.cloudflare.com /samples:5 /dataonly
  • Source: where the server gets its time. Local CMOS Clock or Free-running System Clock means it isn’t syncing.
  • Last Successful Sync Time should be recent.
  • stripchart shows the offset from a reference server. It should be milliseconds, not seconds.

Configure NTP servers (standalone / VPS)

w32tm /config /manualpeerlist:"time.cloudflare.com,0x8 pool.ntp.org,0x8 time.windows.com,0x8" /syncfromflags:manual /reliable:no /update
Restart-Service w32time
w32tm /resync /force
w32tm /query /status
  • 0x8 means client mode with standard intervals.
  • Use several sources, so one outage doesn’t matter.
  • Make sure outbound UDP 123 is allowed (Windows Firewall allows outbound by default).

Make the service start automatically

Set-Service w32time -StartupType Automatic
sc.exe triggerinfo w32time start/networkon stop/networkoff

Improve accuracy

By default, Windows syncs fairly infrequently. For time-sensitive workloads (trading, logging across systems), poll more often:

# poll interval in log2 seconds: 6 = 64 s, 10 = 1024 s
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config /v MinPollInterval /t REG_DWORD /d 6 /f
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config /v MaxPollInterval /t REG_DWORD /d 10 /f
Restart-Service w32time

Windows Server 2016 and later can keep time within about a millisecond with good network conditions.

Virtual machines and the host clock

On virtual machines, the hypervisor may also provide time. On a KVM VPS, rely on NTP inside the guest, as above. If the time is still wildly off after a reboot (for example by hours), check the time zone before suspecting the clock (next section).

Time zone vs time

The clock may be correct in UTC, but displayed in the wrong zone:

Get-TimeZone
Get-TimeZone -ListAvailable | Where-Object Id -like "*Tokyo*"
Set-TimeZone -Id "UTC"                 # common choice for servers
Set-TimeZone -Id "Eastern Standard Time"

Many admins keep servers on UTC, and let applications convert. Trading platforms usually show broker server time regardless of the Windows time zone.

Domain-joined servers

In Active Directory, members sync from domain controllers automatically (/syncfromflags:domhier), and only the PDC emulator should sync from external NTP. Don’t set manual peers on members, or Kerberos authentication may break.

Troubleshooting

Symptom Fix
Source = Local CMOS Clock Configure manual peers (above), then /resync
“The computer did not resync because no time data was available” UDP 123 blocked, or the peer list is wrong
Large offset won’t correct w32tm /resync /force; W32Time may refuse huge jumps, so set the time once (Set-Date), then resync
TOTP codes or API signatures rejected Clock drift: check stripchart
Logs in the wrong hour Time zone, not the clock

Event Viewer → System log, source “Time-Service”, shows sync events and errors. See Windows Event Viewer errors.

Why traders care

Trading platforms compare your server’s clock with the broker’s servers. A drifting clock doesn’t change execution speed, but it can confuse time-based logic in expert advisors, logs and reports, and exchange APIs reject signed requests whose timestamps are too far off. Check w32tm /stripchart after setting up a new trading VPS, and again after major updates.

Quick reference

Task Command
Status w32tm /query /status
Set NTP servers w32tm /config /manualpeerlist:"…" /syncfromflags:manual /update
Force sync w32tm /resync /force
Measure offset w32tm /stripchart /computer:<server>
Time zone Set-TimeZone -Id "UTC"

Related: Windows VPS trading latency and Windows VPS.

  • Windows Server
  • NTP
  • Troubleshooting