I'm using %date:~10%%date:~7,2%%date:~4,2%%time:~0,2%%time:~3,2%
for date
The output should be like : 201706161102
but the output : 016.1102
whats wrong?
I'm using %date:~10%%date:~7,2%%date:~4,2%%time:~0,2%%time:~3,2%
for date
The output should be like : 201706161102
but the output : 016.1102
whats wrong?
I recommend you using the output of the WMIC
command like that :
@echo off
Title Get Date and Time with WMIC
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YYYY=%dt:~0,4%"
set "MM=%dt:~4,2%"
set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%"
set "Min=%dt:~10,2%"
set "Sec=%dt:~12,2%"
echo YYYYMMDDHHMinSec
Set "DateTimeVar=%YYYY%%MM%%DD%%HH%%Min%%Sec%"
echo %DateTimeVar%
pause