Using a date or time stamp in the name of a batchfile

Using the ~ substring operator and the %date% or %time% environment variables, it is possible to insert a date or timestamp into a filename while running a batchfile.

	
testfile_%date:~-4,4%%date:~-7,2%%date:~-10,2%.zip

wil result in something like testfile_20100112.zip