Home » Computers » Windows » DOS variables: %date% and %time%

DOS variables: %date% and %time%

Need to do some date and/or time manipulation in a DOS batch/command file? Here is a good example:

set filedatetime=%date:~10%-%date:~4,2%-%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2%
echo %filedatetime% 2009-01-28_15120393

Hope this helps you with your batch files.