What is the command to sync a Windows workstation or server to its configured time source?

up vote 68 down vote accepted

As Kyle said w32tm /resync is the modern way to do this. See this Link to Microsoft Knowledgebase (KB 307897) for more information on the w32tm command.

There is also net time which is an older version but perhaps easier.

  • 3
    w32tm /resync says "The computer did not resync because the required time change was too big." as my CMOS battery is dead and my computer clock resets on every boot at 1/1/2000 12:00 AM. Any help? – Never Quit Nov 4 '15 at 16:48
  • Found solution as per blog.bruteforcetech.com/archives/911 , do not forget to restart W32Time service net stop W32Time then retry w32tm /resync – Never Quit Nov 4 '15 at 17:14
  • The link is broken. – Stijn Sanders Oct 11 '17 at 9:26
  • 1
    @LightnessRacesinOrbit and the others, if you get the "time change was too big" error, use w32tm /resync /force. But if you don't have the service started, run net start w32time. Both from an elevated prompt. – cdlvcdlv May 25 at 15:13
  • 1
    To solve 'time change was too big' change registry entries MaxNegPhaseCorrection and MaxPosPhaseCorrection in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config to maximum (ffffffff) – Tomas F. Sep 3 at 10:02

For those that still asking this question.

  1. To update, use the command below (2008 and 2012 server compatible)

    w32tm /config /manualpeerlist:"ntp_server" /syncfromflags:manual /reliable:yes /update
    

change the ntp_server with your source

  1. Restart the time service

    net stop w32time
    net start w32time
    
  2. Resync the time

    w32tm /resync
    
  3. Verify your sync status

    w32tm /query /status
    

Commands above should be fine if your sources are working correctly and/or your connection is OK (firewall or Microsoft Forefront can be an issue also). The commands below can help with troubleshooting

To list out peers

w32tm /query /peers

To list out NTP Sources:

w32tm /query /source
  • Nice, comprehensive answer! Definite +1 for the command to set up the NTP server. – Shaamaan Apr 3 '17 at 9:33
  • As a note, this works for Windows 10 Professional without the "/update" flag as that is invalid. – Fmstrat Dec 4 '17 at 15:56

You can use the following command:

w32tm /resync

You can use:

w32tm /resync

Additionally, using w32tm /resync /rediscover will also "force redetection of network resourced before resynchronization."

Or using:

net time /set

Will prompt you to set the time to the DC. (Works for older versions of Windows)

  • For some reason w32tm /resync didn't work for me but net time /SET /Y did. I used /Y for net time because it apparently doesn't read stdin properly when going through sshd from cygwin. – qwertzguy Jan 14 '15 at 3:40
  • When running w32tm /resync I got the message The computer did not resync because no time data was available. even after a service restart but net time /SET worked properly for me. – Chris Magnuson Apr 3 '17 at 12:32

OS: MS Windows 7

All above ideas have been tried but did not help. The original problem still exists: "The computer did not resync because the required time change was too big."

Solution is found in the registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\w32time\Config

  • change this if the local time is in a hurry (e.g. 31-Dec-2050): MaxNegPhaseCorrection
  • change this if the local time is delayed (e.g. 1-Jan-1980): MaxPosPhaseCorrection
  • The default values are 0xD2F0 (i.e. 54000 sec. = 15 hours)

(use Google for more details)

I use this simple win_clock_sync.bat file from Start Menu StartUp:

echo off
echo Sync computer time from internet
echo.
echo Back-up registry w32time\Config
reg export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\w32time\Config exported_w32time.reg /y
rem changing the registry keys temporarly:
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\w32time\Config /v MaxNegPhaseCorrection /d 0xFFFFFFFF /t REG_DWORD /f
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\w32time\Config /v MaxPosPhaseCorrection /d 0xFFFFFFFF /t REG_DWORD /f
echo.
echo w32tm /config /update
w32tm /config /update
echo.
echo w32tm /resync /rediscover 
w32tm /resync /rediscover 
echo.
echo Restore registry w32time\Config
reg import exported_w32time.reg

Enjoy! :-)

  • Your answer could use an explanation of the function of the MaxNegPhaseCorrection and MaxPosPhaseCorrection values instead of suggesting that they should be blindly disabled. That's what this script does by setting their data to 0xFFFFFFFF. – Twisty Impersonator May 13 '17 at 18:45
  • You cannot ignore the mentioned error message "The computer did not resync because the required time change was too big." without changing the data in the MaxNegPhaseCorrection and MaxPosPhaseCorrection values. Or, did YOU find any working solution to the original problem?? And why are you writing "blindly"? If you would take a short time to read through then you could see the exporting and importing the original data of these values, what is a bit far from doing something "blindly". – Akos May 14 '17 at 7:50
  • You should have this script change the values to disabled, force an update, and then change them back to recommended values. – Cory Knutson Jun 2 '17 at 18:57
  • Twisty has valid points that do not really focus on the issue raised by NeverQuit... but then Akos has not clearly explained why the script is an appropriate solution for NeverQuit. In essence, the Registry values MaxNegPhaseCorrection and MaxPosPhaseCorrection exist to stop the W32Time service from applying dramatic changes to current time [in circumstances such as an external time source going badly awry] However, if some issue occurs that leads to a PDCe drifting rapidly from a reliable time source, then the correction controls will prevent w32tm fixing the big drift. In this situation::: b – Creaky_Uncle_Nick Jul 6 '17 at 10:32
  • @Akos Downvote retracted based on your pointing out that your script indeed does revert the changes to the MaxNegPhaseCorrection and MaxPosPhaseCorrection values. I still encourage including an explanation of what these two settings do as they're a key feature of your answer and it's important that an admin be aware that should they put these settings in place permanently they would configure their system to accept any time change, no matter how large, which could break Kerberos and other important network services. – Twisty Impersonator Jul 7 '17 at 2:39

Powershell one liner if ntp server is configured:

gsv w32time | sasv; w32tm /resync /force

You can put this .bat file in the startup if you CMOS batery failed so it can resync upon OS start:

@powrshell -NoProfile -Command 'gsv w32time | sasv; w32tm /resync /force'
  • /force is not a documented command-line option for w32tm /resync. – Dai Sep 10 at 20:39
net start w32time
w32tm /resync

According to Riot Games

Try in this order. Works all the time.

w32tm /unregister

w32tm /register

net stop w32time

net start w32time

w32tm /resync

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.