@echo off
echo %%date%%=%date%
echo 年 = %%date:~0,4%% = %date:~0,4%
echo 月 = %%date:~5,2%% = %date:~5,2%
echo 日 = %%date:~8,2%% = %date:~8,2%
echo:
echo %%time%%=%time%
set NowTime=%time: =0%
set hh=%NowTime:~0,2%
set mm=%NowTime:~3,2%
set ss=%NowTime:~6,2%
echo hh=%hh%
echo mm=%mm%
echo ss=%ss%
pause
@ECHO OFF
For /F "tokens=1-3 delims=/ " %%a IN ('DATE /t') DO (SET DATE=%%a-%%b-%%c)
SET NowTime=%time: =0%
ECHO %DATE%-%NowTime:~0,2%-%NowTime:~3,2%-%NowTime:~6,2%
PAUSE
Batch Get Date Time