TIME

Display or set the system time.

Syntax
 TIME [new_time]
 TIME
 TIME /T
Key
 new_time : The time as HH:MM
 TIME with no parameters will display the current time and prompt 
 for a new value. Pressing ENTER will keep the same time.
 /T : Just display the time, formatted according to the current Regional settings.

Time Formatting

In Control Panel, Regional settings a Time Appearance can be set. This can be used to change the separator, and the number of characters used to display hours and minutes.

The time Separator, Country Code and Time format can be read from the registry using REG as follows:

@Echo off
FOR /F "TOKENS=3" %%D IN ('REG QUERY ^"HKEY_CURRENT_USER\Control Panel\International^" /v iCountry ^| find ^"REG_SZ^"') DO (
 SET _country_code=%%D)
Echo Country Code %_country_code%
FOR /F "TOKENS=3" %%D IN ('REG QUERY ^"HKEY_CURRENT_USER\Control Panel\International^" /v sTime ^| find ^"REG_SZ^"') DO (
 SET _time_sep=%%D)
Echo Separator %_time_sep%
FOR /F "TOKENS=3" %%D IN ('REG QUERY ^"HKEY_CURRENT_USER\Control Panel\International^" /v sTimeFormat ^| find ^"REG_SZ^"') DO (
 SET _time_format=%%D)
Echo Format %_time_format%

Country Codes/Formats

The default time formats for different country codes are below.
These values are user changeable so it is not safe to assue the default will be correct for any particular user.

 Country/language Date format Time format Country
 Code
 United States MM/dd/yyyy H:mm:ss.tt 001
 
 Czechoslovakia dd.MM.yyyy HH:mm:ss 042
 France dd.MM.yyyy HH:mm:ss,tt 033
 Germany dd.MM.yyyy HH:mm:ss,tt 049
 Latin America dd/MM/yyyy H:mm:ss.tt 003
 Intl. English dd/MM/yyyy HH:mm:ss.tt 061
 Portugal dd-MM-yyyy HH:mm:ss 351
 Finland d.M.yyyy HH.mm.ss 358
 Switzerland dd.MM.yy HH mm.ss 041
 Norway dd.MM.yy HH:mm:ss 047
 Belgium dd/MM/yy HH:mm:ss 032
 Brazil dd/MM/yy HH:mm:ss 055
 Italy dd/MM/yy HH.mm.ss 039
 United Kingdom dd/MM/yy HH:mm:ss 044
 Denmark dd-MM-yy HH.mm.ss 045
 Netherlands dd-MM-yy HH:mm:ss 031
 Spain d/MM/yy HH:mm:ss 034
 Hungary yyyy.MM.dd HH:mm:ss 036
 Canadian-French yyyy-MM-dd HH:mm:ss 002
 Poland yyyy-MM-dd HH:mm:ss 048
 Sweden yyyy-MM-dd HH.mm.ss 046
yyyy = 4 digit year
 yy = 2 digit year
 dd = 2 digit day
 d = 1/2 digit day
 HH = 2 digit Hour
 H = 1/2 digit hour
 mm = 2 digit minutes
 ss = 2 digit seconds
 tt = AM/PM indicator
 t = a/p indicator

Errorlevels

If the time was successfully changed (or not given) %ERRORLEVEL% = 0
If it fails, e.g. the user lacks the privilege %ERRORLEVEL% = 1

TIME is an internal command. In early versions of Windows, disabling Command Extensions will disable the /T switch.

Examples

Display the time:

C:\> TIME /t
09:27

Display the time including Seconds and Hundredths of a second:

C:\> ECHO:| TIME
The current time is: 09:28:55.73

"Chronos Time is quantitative - seconds and minutes, Kairos Time is qualitative - it measures the right, opportune moment" ~ Greeks words for time.

Related commands

%TIME% - Dynamic variable containing the current time HH:mm:ss.
DATE - Display or change the date.
NOW - Display Message with Current Date and Time.
W32TM - Time Service.
TZUTIL - Time Zone Utility.
GetTime.cmd - Script to get current time.
GMT.cmd - Current time in GMT (World Time).
Custom date and time format strings - Microsoft.com
The Time Zone Database - IANA.
Equivalent PowerShell: Get-Date - Get current date and time.
Equivalent bash command (Linux): date - Display or change the date & time.

(追記) (追記ここまで)
Copyright © 1999-2026 SS64.com
Some rights reserved

AltStyle によって変換されたページ (->オリジナル) /