Skip to content

datetime

Vurdalakov edited this page Feb 24, 2015 · 1 revision
Overview

datetime command-line tool prints date and/or time in specified format.

Syntax
datetime [/options]

/format option sets the date and/or time output format. See here for details.

/adddays option adds the specified number of days to the current date. The number of days can be negative or positive.

/newline option adds a new line (CRLF) after output.

Examples
datetime
datetime /format:"dd.MM.yyyy HH.mm.ss.ffff"
datetime /adddays:-1 /format:yyyyMMdd
datetime /newline

Usage in .BAT files:

for /f "usebackq" %%i in (`datetime.exe /adddays:-1 /format:yyyy-MM-dd`) do set date=%%i
echo %date%
Clone this wiki locally