Update: Now that it\'s 2016 I\'d use PowerShell for this unless there\'s a really compelling backwards-compatible reason for it, particularly because of the regional setting
Unfortunately this is not immune to regional settings, but it does what you want.
set hour=%time:~0,2% if "%time:~0,1%"==" " set hour=0%time:~1,1% set _my_datetime=%date:~10,4%-%date:~4,2%-%date:~7,2%_%hour%%time:~3,2%
Amazing the stuff you can find on Wikipedia.