1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| @echo off
rem 取得今天日期的年、月、日三個欄位(透過 date /t 指令取得) for /f "tokens=1-4 delims=-/ " %%i IN ('date /t') DO ( set year=%%i set month=%%j set day=%%k set week=%%l )
rem 取得當下時間的時、分兩個欄位 for /f "tokens=1-3 delims=:" %%i IN ('time /t') DO ( set hour=%%i set minute=%%j )
rem 濾掉 hour 前面可能會出現的空白以及上午下午的文字 for /f "tokens=1-2 delims= " %%i IN ("%hour%") DO ( set hour=%%j )
echo "====== Start ======" echo "date parameter = %date%" echo "time parameter = %time%" echo "year = %year%" echo "month = %month%" echo "day = %day%" echo "week = %week%" echo "minute = %minute%" echo "hour = %hour%" echo "====== End ======" pause
|