time - Batch how to print DateTime -


i having batch syntax prints datetime. here is

echo mydatetime_%date:~-4,4%_%date:~-7,2%d_%date:~-10,2%m_%time:~0,2%hr-%time:~3,2%min-%time:~6,2%sec 

i want return

mydatetime_2015_22d_04m_9hr-41min-06sec 

but returning

mydatetime_2015_22d_04m_ 9hr-41min-06sec 

a space between 04m_ 9hr. dont understand why space generating ?

set "dt=mydatetime_%date:~-4,4%_%date:~-7,2%d_%date:~-10,2%m_%time:~0,2%hr-%time:~3,2%min-%time:~6,2%sec" echo %dt: =% 

try this

check this