Programming Field

Time - DOS/Command Prompt Reference

Displays the current time and sets a new time if necessary.

Syntax

time [<time>]
time /T
<time>

Specifies a new time. The time format depends on the system settings. ([MS-DOS] The format depends on COUNTRY directive (in config.sys).)

If you omit <time>, Time will display the current time and prompt for a new time.

/T [Windows NT series] [Extensions] Displays the current time only (does not prompt). The output value may be slightly different from the environment variable TIME (see also ‘%’ page).

Details

Usage of Time

Time displays the current time. If you do not specify the time, Time prompts for a new time, so you can enter the new if you want to change the time. If you don't want to change the time, simply enter the newline without any input.

To display or change the current date, use Date command.

[MS-DOS (except for Windows 95 and later)] In case Autoexec.bat doesn't exist, Command.com prompts for the date and the time as if Date and Time commands are executed at startup. If you want to skip this, you need to create Autoexec.bat.

Samples

Sample

echo.| time

Displays the current time but skips entering a new time. (Sending newline by using Echo.)