@echo off echo %date% set datet=%date:~0,4%%date:~5,2%%date:~8,2% echo %datet% pause
~0:表示从索引0开始取
,4:取4个字符