Pages

Thursday, December 1, 2022

How to Set the Timezone and Configure NTP on Windows Server

How to Set the Timezone and Configure NTP on Windows Server


Network Time Protocol (NTP) is a highly scalable internet protocol that determines the best time information and synchronizes accurate settings on a computer system. This guide explains how to set the time zone and configure NTP on a Windows Server.

This guide uses Windows Server 2019, but these instructions work on any machine with Server 2016 or later.

Prerequisites

Before you begin:

Set the Timezone

Windows Timezone Settings

  1. Using the Windows Start Menu, open Server Manager.
  2. Locate Time zone in the local server properties section.
  3. Click the current timezone, which is UTC Coordinated Universal Timeby default.
  4. In the Date and Time window, click Change time zone.
  5. Expand the Time zone drop-down list.
  6. Select your preferred timezone. It's recommended to set it to your server location.
  7. Click OK to save changes.
  8. Click Apply to load changes on the server.
  9. Re-open Server Manager, and verify the timezone change.

Optional: Set the Timezone using PowerShell

  1. From the start menu, open Windows PowerShell, or open the run dialog (Win key + R), type powershell in the search bar, and click OK to start PowerShell.
  2. Run the following command to check the server timezone.

    PS > Get-Timezone
    
  3. View all available timezones.

    PS> Get-Timezone -ListAvailable
    

    To find your target timezone, use the following command to filter by name.

    PS> Get-Timezone -ListAvailable | Where-Object {$_.displayname -like "*US*"}
    

    The command above displays all names containing the characters US. You can use a different string such as London.

  4. Change your timezone.

    PS> Set-Timezone -Name "Central Standard Time"
    

    You can also change the timezone by ID.

    PS> Set-Timezone -Id "Central Standard Time"
    

Configure NTP

In addition to setting the timezone, you can also configure Windows to use NTP to synchronize the time.

  1. Open the Run dialog window by pressing the Windows key (WIN) + R on your keyboard.
  2. In the search bar, enter regedit and click OK to open Registry Editor.
  3. Expand the registry navigation tree:

    HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Services

  4. Expand W32Time.

  5. Click Config.
  6. Select AnnounceFlags
  7. Enter 5 in the Value data field.
  8. Click OK to save changes.
  9. In the left pane, click Parameters.

Optional: Change the NTP Server

By default, Vultr uses the time.constant.com time server, located on our high-speed infrastructure. If you want to use a different time server, you can change the value of the NtpServer parameter by following these steps.

  1. Double-click NtpServer
  2. Change the value data field to your preferred value. For example, to sync with the United States NTP pool, use:

    us.pool.ntp.org
    

    You can find a list of NTP Pool servers at the official website.

  3. Expand TimeProviders.

  4. Click NtpServer.
  5. Double click Enabled, change the value data from 0 to 1, and click OK to save changes.
  6. Close the registry editor, open the start menu, and search the keyword services.
  7. In the services window, scroll through the list, select Windows Time, right-click, and select Restart to apply NTP changes.

    Restart the Windows Time Service

Optional: Configure NTP Using PowerShell

If you prefer to use Powershell, you can use the following commands to configure NTP.

  1. Open PowerShell with administrative privileges.
  2. Check the NTP time synchronization status.

    PS> w32tm /query /status
    
  3. Enter the following command to set the time AnnounceFlags to 5.

    PS> Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\services\W32Time\Config" -Name "AnnounceFlags" -Value 5 
    
  4. (Optional) If you want to use NTP pool servers instead of Vultr's NTP server, run the following command.

    PS> Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\w32time\Parameters" -Name "NtpServer" -Value us.pool.ntp.org
    
  5. Enable NTP Server.

    PS> Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\w32time\TimeProviders\NtpServer" -Name "Enabled" -Value 1
    
  6. Restart the Windows Time service.

    PS> Restart-Service w32Time
    
  7. Test NTP synchronization.

    PS> w32tm /resync

No comments: