2.7. Setting the System Time, Date, and Time Zone


You want to set the system time, date, and time zone.


Using a graphical user interface

  1. From the Control Panel, open the Date and Time applet. This can also be accomplished by double-clicking the clock on the system tray or running timedate.cpl from the command line.

  2. You can configure the year, month, day, and time on the Date & Time tab and the time zone on the Time Zone tab.

  3. On Windows Server 2003, you can configure clock synchronization (Network Time Protocol (NTP) settings) from the Internet Time tab if the system is not part of a domain. If it is member of a domain, then the clock is synchronized automatically from an Active Directory domain controller.

Using a command-line interface

The following commands set the time to 11:02 p.m. and the date to November 1, 2005:

> time 23:02:00
> date 11/01/2005

The date format may vary depending on your locale.

Run this command to display the current date, time, and time zone:

> date /t & time /t & w32tm -tz

You can use this command to display time zone information from the registry:

> reg query \\<ServerName>\HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation

This command sets the SNTP server list:

> net time /setsntp:<ServerList>

For example:

> net time /setsntp:mytime.rallencorp.com,time.windows.com

This command queries the SNTP server:

> net time /querysntp

This command forces the local system to sync its time from the time source:

> net time /set

Using VBScript

' This code displays ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.