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.
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.
To display the time including Seconds and Hundredths of a second:
ECHO:| TIME
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%
The default time formats for different country codes are below.
Thses 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 033 Germany dd.MM.yyyy HH:mm:ss 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
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. If Command Extensions are disabled TIME will not support the /T switch
“Time is like money, the less we have of it to spare, the further we make it go” - Josh Billings
Related:
%TIME% - variable containing 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.
Timethis - Time how long it takes the system to run a command. (Win
2K ResKit).
Uptime - Time since last reboot. (Win 2K
ResKit).
GetTime.cmd - Script to get current time.
GMT.cmd - Current time in GMT (World Time).
Custom date and time format strings - Microsoft.com
Powershell: Get-Date - Get current date and time.
Equivalent bash command (Linux): date - Display or change the date & time.