Skip to content

COGMLS/WindowsDateTimeSyncFix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Windows Date Time Sync Fix

Windows Date Time Synchronization Fix is a solution created to fix the Windows 10 and Windows 11 clock (time and date) sync. This solution fixes the date and time based on local time zone configuration, getting from an open server (worldtimeapi.org) the UTC date. Using the local time zone, it calculates the difference and applies the correct values into Windows clock, fixing the outdated Windows clock.

To force a date and time sync on your Windows, execute your Windows PowerShell (version 5.0 or higher) or PowerShell with administrator rights. Otherwise, it will enter in test mode, and no change will be applied.

Important

This script does not send any personal data to the server and does not save any data from the internet.

Note

The connection with the server may need multiple tries.

Note

Originally this solution was designed to use a Python 3 script and was recreated to work directly with PowerShell features, bringing more performance and less chances to make a significant delta time between the acquired time from server and processed time to apply on Windows Clock. The original Python script has deprecated and is archived here.

Using the script:

To use the script is just necessary to execute it with Windows PowerShell or the PowerShell console and have an internet connection to be able to communicate with the server. With you want to test the script without applying any modification, use the -Test on command line.

Example to synchronize and apply the correct date and time (Note: The captured console output is in Brazilian Portuguese format. The output will depend on your system regional settings):

C:\Users\admin\Scripts> & .\WinDateTimeSync.ps1

Windows Date Time Sync - 1.0.2
-----------------------------------------------------------------
Trying connection... (1/10)
Status: 0 Description: OK

quarta-feira, 29 de outubro de 2025 15:36:25
System's clock defined to 10/29/2025 15:36:25 with success!

Script commands:

The script has a help command line that can be accessed with the cmdlet Get-Help:

# Assuming the current working directory has the script:
Get-Help .\WinDateTimeSync.ps1
Command(s) Description Notes
Test Use the script without applying modification on your system If the script is not execute with Administrator Rights, the TestMode will be applied automatically.
DebugScript Enable the script debug mode, showing processed data and status code
Tries Set a custom number of tries to connect with server (Default is 10) Any value set value below then one will return error 8
Experimental Enable the script experimental features Using this parameter may lead to unexpected behavior
Info Show extra information about the script procedures Using this parameter will enable some verbose information output, but not all. To see all detailed information, use -Verbose and/or -DebugScript parameters

Documentation:

Documentation Description
ProjectInfo.md General project development information, including known bugs, deprecated or removed features. It also contains the recent and future features planned to be implemented
ProjectReleases.md Contains all project releases and modifications.

Releases:

1.0.2 | Release Date: 2025/10/29
Fixed incompatibility with Windows PowerShell when reaching the variable IsWindows, which is available only on PowerShell
Added experimental parameter Wait. NOTE: This feature is under development
[BUG] Executing the script on Windows PowerShell will not work as expected.
Updated minimum PowerShell version requirement to 5.0 This fixes a minimum requirement for use classes on PowerShell.
1.0.1 | Release Date: 2025/10/03
Fixed parameter Tries not working on Windows PowerShell
Fixed parameter Tries not working as expected on PowerShell
Changed uint datatype variables to Int32 avoiding incompatibility with Windows PowerShell
1.0.0 | Release Date: 2025/09/10
Added new comments and documentation for the PowerShell script
Added new help examples inside the script's help
Added Info parameter to print some information about the operations. (This parameter brings less information output than Verbose parameter)
Promoted custom connection tries to stable features
Small changes on cli check
0.9.0 | Release Date: 2025/09/05
Added generic description for HTTPResponseData
Minor changes on console output, while gathering server information
Fixed IsElevated method
Fixed HTTPResponseData status description
0.8.0 | Release Date: 2025/07/24
Added experimental custom number of connection tries
Added test mode on PowerShell script
Added debug information output
Added platform test
Added main entry
Added script presentation
Added exit with error codes
Added variable controls
Added help command line
Added cli test for debug and experimental options
Added date and time extraction in UTC format from json content
Added local date and time getter information
Added local timezone configuration extraction
Added delta date and time between UTC server and local information
Added sum of delta time with local time
Added HttpResponseData class
Added getDateTimeInfo method
Added loop to try and get the date time information
This version is based on all implementations made in deprecated Python script

License

A copy of the license file is available here

MIT License

Copyright (c) 2025 Matheus Lopes Silvati

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Mitigation for Windows date and time synchronization fail

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published