本帖最后由 flashercs 于 2019-11-21 18:01 编辑
- @echo off
- set "起始时间=08:25:39.80"
- set "终止时间=19:51:42.00"
-
- set "mytime=%起始时间%"
- call :getTod time_1
- set "mytime=%终止时间%"
- call :getTod time_2
- set "mytime=%time%"
- call :getTod time_3
- set /a "time_dist1=time_2-time_1"
- if %time_dist1% LSS 0 set /a "time_dist1+=8640000"
- set /a "time_dist2=time_3-time_1"
- if %time_dist2% LSS 0 set /a "time_dist2+=8640000"
-
- if %time_dist2% lss %time_dist1% (
- goto label
- ) else (
- exit /b
- )
-
- :label
- echo now is %time%
- pause
- exit /b
-
- :getTod -- get a Time of Day value in 1/100th seconds
- :: -- %~1: out - time of day
- SETLOCAL
- set t=%mytime: =0%
- set /a t=((1%t:~0,2%*60+1%t:~3,2%)*60+1%t:~6,2%)*100+1%t:~9,2%-36610100
- ( ENDLOCAL & REM RETURN VALUES
- IF "%~1" NEQ "" SET %~1=%t%
- )
- GOTO:EOF
复制代码
|