- @echo off
- title 修改系统时间为30秒前
- setlocal enabledelayedexpansion
- echo 修改前^: %time%
- for /f "delims=^: tokens=1,2,3*" %%i in ("%time%") do (
- set TH=%%i
- if "!TH:~0,1!"=="0" set/a TH=!TH:~1,1!
- set TN=%%j
- if "!TN:~0,1!"=="0" set/a TN=!TN:~1,1!
- set TS=%%k
- set TS=!TS:~0,2!
- if "!TS:~0,1!"=="0" set/a TS=!TS:~1,1!
- )
- set/a SS=%TH%*3600 + %TN%*60 + %TS%
- set/a SS=%SS% - 30 && @REM 向前30秒
- set/a TH=%SS% / 3600
- set/a TN=(%SS% - %TH% * 3600) / 60
- set/a TS=%SS% - (%TH% * 3600) - (%TN% * 60)
- set TH=00%TH%
- set TN=00%TN%
- set TS=00%TS%
- set TH=%TH:~-2%
- set TN=%TN:~-2%
- set TS=%TS:~-2%
- time %TH%^:%TN%^:%TS%
- if %errorlevel%==0 echo 修改后^: %time%
- pause
复制代码
|