批处理如何显示时间格式为20090313095040

2024-12-16 07:15:46
推荐回答(2个)
回答1:

@echo off
set /a tm1=%time:~0,2%*1
if %tm1% LSS 10 set tm1=0%tm1%
echo %date:~0,4%%date:~5,2%%date:~8,2%%tm1%%tm2%%tm3%%time:~3,2%%time:~6,2%
pause

结果:
20120710191105

回答2:

set d=%date:~,10%
set d=%d:-=%
set t=0%time:~,8%
set t=%t: =%
set t=%t::=%
echo %d%%t%