Home > Commands N-Z > Commands T

TIME


Description | Syntax | Parameters | Switches | Related | Notes | Examples | Errorlevels | Availability

Displays the system time or sets your computer's internal clock.

The operating system uses time information to update the directory whenever you create or change a file.


Syntax

TIME /?

TIME [hours:[minutes[:seconds[.hundredths]]][A|P[M]]]

Display the current time or to display a prompt by which you can change the current time:

TIME [/T[IME]]


Parameters
A[M] | P[M] (v5.0 Win95 NT3.5)
Specifies A.M or P.M. for the 12-hour time format. If you type a valid 12-hour time but do not type A or P, TIME uses A (for A.M.).
hours: (v1.0 Win95 NT3.5)
Specifies the hour. Valid values are in the range 0 through 23.
hundredths (v1.0 Win95 NT3.5)
Specifies hundredths of a second. Valid values are in the range 0 through 99.
minutes (v1.0 Win95 NT3.5)
Specifies minutes. Valid values are in the range 0 through 59.
seconds (v1.0 Win95 NT3.5)
Specifies seconds. Valid values are in the range 0 through 59.

Switches
/? (NTXP)
Displays help.
/T (NT4)
/T[IME] (NT2003)
Just display the time, formatted according to the current Regional settings.

Related

For information about changing the current date, see the DATE command.
For information about changing the time format, see the COUNTRY command.
NOW - Display Message with Current Date and Time.
TIMESERV - Time Service (resource kit).
W32TIME - Time Service (y2K compliant update for TIMESERV).
Equivalent Linux BASH commands:
date - Display or change the date & time.


Notes
Command Extensions

If Command Extensions are disabled TIME will not support the /T switch.


Time formats for different country codes
 Country or language CountryCode Date format Time format
   United States         001          01/03/1994  5:35:00.00p
   Czechoslovakia        042          03.01.1994 17:35:00
   France                033          03.01.1994 17:35:00
   Germany               049          03.01.1994 17:35:00
   Latin America         003          03/01/1994  5:35:00.00p

   International English 061          03/01/1994 17:35:00.00
   Portugal              351          03-01-1994 17:35:00
   Finland               358          3.1.1994   17.35.00
   Switzerland           041          03.01.94   17 35.00
   Norway                047          03.01.94   17:35:00

   Belgium               032          03/01/94   17:35:00
   Brazil                055          03/01/94   17:35:00
   Italy                 039          03/01/94   17.35.00
   United Kingdom        044          03/01/94   17:35:00.00
   Denmark               045          03-01-94   17.35.00

   Netherlands           031          03-01-94   17:35:00
   Spain                 034          3/01/94    17:35:00
   Hungary               036          1994.01.03 17:35:00
   Canadian-French       002          1994-01-03 17:35:00
   Poland                048          1994-01-03 17:35:00

   Sweden                046          1994-01-03 17.35.00
 Country or language CountryCode Date format Time format

Registry Country Code

The Country Code is a user setting in the registry:

    [HKEY_CURRENT_USER\Control Panel\International]
    "iCountry"="44"

The Country Code can be read using REG as:

    FOR /F "TOKENS=2,3*" %%A IN ('REG QUERY "HKEY_CURRENT_USER\Control Panel\International\iCountry"') DO (FOR %%G IN (%%A) DO (SET v_country=%%G))

Registry Time Separator

The time separator is also a registry setting:

    [HKEY_CURRENT_USER\Control Panel\International]
    "sTime"=":"

The time separator can be read using REG as:

    FOR /F "TOKENS=2,3*" %%A IN ('REG QUERY "HKEY_CURRENT_USER\Control Panel\International\sTime"') DO (FOR %%G IN (%%A) DO (SET v_time_sep=%%G))

Specifying an invalid TIME format

If you specify the time in an invalid format, the operating system displays the message and then waits for you to specify the time:

    Invalid time
    Enter new time:

Changing the TIME format

You can change the TIME format by changing the COUNTRY setting in your CONFIG.SYS file. For more information, see the COUNTRY command. Depending on the country code, the operating system will display the time in the 12-hour format or the 24-hour format. If you are setting the time in the 12-hour format, be sure to specify P for hours after noon.


Ensuring that the operating system prompts you for the time

If you want the operating system to prompt you for the current time whenever you start your system, you can add the TIME command to your AUTOEXEC.BAT file. The operating system will automatically prompt you for the time and date if you do not have an AUTOEXEC.BAT file.


Modifying computer system clock

Prior to v3.30, DATE did not modify the computer system clock (You had to use SETUP disk).


Examples

To set your computer's clock to 1:36 P.M., use either of the commands:

    TIME 13:36
    TIME 1:36p

Errorlevels

none.


Availability
External
DOS
v1.0 v1.05
Internal
DOS
v1.1 v1.11 v1.24 v1.25 v1.85 v2.0 v2.01 v2.05 v2.10 v2.11 v2.11R v2.12 v2.2 v2.25 v3.0 v3.20 v3.05 v3.1 v3.21 v3.25 v3.30 v3.3A v3.3R v3.3T v3.31 v3.40 v4.0 v4.01 v4.01A v5.0 v5.0A v5.00.02 v5.001A v5.01 v5.02 v6.0 v6.10 v6.2 v6.21 v6.22 v6.23 v7.00 v7.0R1 v7.10 v8.00
Windows
Win95 Win98 WinME
Windows NT
NT3.5 NT4 NT2000 NTXP NT2003