Skip to content

Instantly share code, notes, and snippets.

@HackingGate
Created April 23, 2025 14:39
Show Gist options
  • Save HackingGate/180aafbc6342ad4b1cb31309fa83c91a to your computer and use it in GitHub Desktop.
Save HackingGate/180aafbc6342ad4b1cb31309fa83c91a to your computer and use it in GitHub Desktop.
PowerShell Script to Set Windows RTC to UTC
<#
.SYNOPSIS
Configures Windows to interpret the hardware clock (RTC) as Coordinated Universal Time (UTC).
.DESCRIPTION
This script adds or updates the 'RealTimeIsUniversal' DWORD value in the Windows Registry
at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation.
Setting this value to 1 tells Windows to treat the hardware clock as UTC,
aligning its behavior with most Linux distributions (like Ubuntu) and resolving
time discrepancies in dual-boot environments.
This script requires administrator privileges to modify the Registry.
.NOTES
Author: Gemini
Date: April 23, 2025
#>
# Define the registry path and value name
$regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation"
$valueName = "RealTimeIsUniversal"
$valueData = 1 # 1 means treat RTC as UTC
# Check if the script is running with administrator privileges
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Warning "This script needs to be run with administrator privileges to modify the Registry."
Write-Warning "Right-click the PowerShell script file and select 'Run as administrator'."
exit
}
Write-Host "Attempting to configure Windows to use UTC for the hardware clock..."
# Check if the registry key exists, create it if not (though it usually exists)
if (-not (Test-Path $regPath)) {
Write-Warning "Registry path '$regPath' not found. Attempting to create it."
try {
New-Item -Path $regPath -Force | Out-Null
Write-Host "Registry path created."
}
catch {
Write-Error "Failed to create registry path. Error: $($_.Exception.Message)"
exit
}
}
# Set the RealTimeIsUniversal registry value
try {
New-ItemProperty -Path $regPath -Name $valueName -Value $valueData -PropertyType DWord -Force | Out-Null
Write-Host "Registry value '$valueName' set to '$valueData' successfully."
Write-Host "Windows will now interpret the hardware clock as UTC."
Write-Host "You may need to reboot your computer or synchronize time for the change to take full effect."
}
catch {
Write-Error "Failed to set registry value '$valueName'. Error: $($_.Exception.Message)"
}
@HackingGate
Copy link
Author

HackingGate commented Apr 23, 2025

Run PowerShell as Administrator:

Invoke-Expression (Invoke-WebRequest -Uri "https://gist.githubusercontent.com/HackingGate/180aafbc6342ad4b1cb31309fa83c91a/raw/877194bc9fa9dfb85afc8bce85537e61448283b8/set-windows-rtc-to-utc.ps1" -UseBasicParsing).Content

Sync time from Settings
Reboot to BIOS to see if the hardware time reflects in UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment