1. 程式人生 > >批處理獲取當前時間指令碼

批處理獲取當前時間指令碼

  批處理檔案獲取當前日期字串:

::獲取當前時間,格式:20160615.095802
for /f "tokens=2 delims==" %%a in ('wmic path win32_operatingsystem get LocalDateTime /value') do (
  set t=%%a
)
set hour=%time:~0,2%
if %hour% geq 10 (set Time=%t:~0,8%.%t:~8,6%) else (set Time=%t:~0,8%.0%t:~9,5%)
echo %Time%
pause