Programming Field

Date - DOS/Command Prompt Reference

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

Syntax

date [<date>]
date /T
<date>

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

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

/T [Windows NT series] [Extensions] Displays the current date only (does not prompt). The output value is almost the same as the environment variable DATE (see also ‘%’ page).

Details

Usage of Date

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

To display or change the current time, use Time 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.| date

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