This depends on the regional settings of the computer, so first check the output of the date using the command prompt or by doing an echo of date.
To do so, create a batch file and add the below content
echo %date%
pause
It produces an output, in my case it shows Fri 05/06/2015.
Now we need to get rid of the slash (/)
For that include the below code in the batch file.
set temp=%DATE:/=%
if you echo the "temp", you can see the date without the slash in it.
Now all you need to do is formatting the date in the way you want.
For example I need the date in the format of YYYYMMDD, then I need to set the dirname as below
To explain how this works, we need to compare the value of temp
Fri 05062015.
now position each characters with numbers starting with 0.
Fri 0506201 5
01234567891011
So for the date format which I need is 20150605,
The Year 2015, in which 2 is in the 8th position, so from 8th position till 4 places, it will make 2015.
The month 06, in which 0 is in the 6th position, so from 6th position till 2 places, it will make 06.
The day 05, in which 0 is in the 4th position, so from 4th position till 2 places, it will make 05.
So finally to set up the final format, we have the below.
SET dirname="%temp:~8,4%%temp:~6,2%%temp:~4,2%"
To enhance this date format with "-" or "_" in between the date, month and year , you can modify with below
SET dirname="%temp:~8,4%-%temp:~6,2%-%temp:~4,2%"
or
SET dirname="%temp:~8,4%_%temp:~6,2%_%temp:~4,2%"
So the final batch code will be
======================================================
@echo off
set temp=%DATE:/=%
set dirname="%temp:~8,4%%temp:~6,2%%temp:~4,2%"
mkdir %dirname%
======================================================
The directory will be created at the place where this batch executes.