From time to time, Windows might act funny and show the wrong time. If that ever happens to you, you can force sync Windows time with a single command. Let me show you how.
Note: To use the Windows time sync command, you need to have admin privileges. If you don't have admin privileges, use the second alternative method.
Related: How to fix Windows showing the wrong time.
Command to Sync Time in Windows
To force sync time in Windows with command prompt, all you have to do is execute a single line command.
First, open the start menu, search for "Command Prompt", right-click on the result and select "Run as Administrator" option.
In the Command Prompt window, execute the following command. As soon as you execute the command, Windows will resync the time based on your current timezone. In case you are wondering, the time zone is automatically set depending on your location. Also, the time details are updated from the default Windows Internet Tim Server time.windows.com.
If your Windows system in on a domain then the above command might not work. In those situations, use the below command.
Note: Sometimes, you might see "The computer did not resync because no time data was available" error. This is fairly common. Especially in Windows 7 and 8. Just try to execute the command multiple times and it should work eventually.
Like I said before, Windows uses time.windows.com as the default time server. If that time server is not working for you or if you want to use some other custom time server, you can do that too.
Open the command prompt as admin and execute the following command. Don't forget to replace time.server.url.com with the actual time server URL. You can use the NTP Pool Project to find the time server addresses of different countries and places.
w32tm /config /update /manualpeerlist:time.server.url.com
As soon as you execute the command, Windows will access that time server, gets the time and syncs it with your system.
That is it. This is the Windows time sync command.
Alternative Way to Sync Time in Windows 10
As an alternative, you can also sync the time via Windows 10 PC Settings app. In fact, compared to the command prompt or the old time settings tool, the new options in the PC Settings are far more easy to access and use.
To sync time via the Settings app, open the Settings app first by pressing the keyboard shortcut Win + I.
In the Settings app, go to "Time & Language -> Date & Time" page. On the right-panel, click on the "Sync" button under the Synchronize your clock section.
As soon as you click the button, Windows will sync the time. Again, as I said before, Windows uses the default time server to sync the time. If you want to sync time via another server then use the above command to sync Windows time.
Hopefully, that helps. Comment below if you are facing any problems with the above methods. I will try to help you as much as possible.
If you are dual booting Windows with other Linux system then Windows and Linux may show different times for other reasons. Follow the linked post to fix that issue.