O'Reilly logo

Windows Server Cookbook by Robbie Allen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

Problem

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

Solution

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required