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
Combine Powershell
into a batch file and use the meta variables to assign each:
@echo off
for /f "tokens=1-6 delims=-" %%a in ('PowerShell -Command "& {Get-Date -format "yyyy-MM-dd-HH-mm-ss"}"') do (
echo year: %%a
echo month: %%b
echo day: %%c
echo hour: %%d
echo minute: %%e
echo second: %%f
)
You can also change the the format if you prefer name of the month MMM
or MMMM
and 12 hour to 24 hour formats hh
or HH