IT运维笔记


批处理计算10分钟前的时间

@echo off
::计算10分钟前的时间
set time_begin=%time:~0,8% 
set /a hour=%time_begin:~0,2%
set /a minute=%time_begin:~3,2%
set  second=%time_begin:~6,2%

if %minute% LSS 10 (
set /a minute=minute+50
set /a hour=hour-1
) else set /a minute=minute-10

if %hour% LSS 10 set  hour=0%hour%
if %minute% LSS 10 set  minute=0%minute%

set mtime=%date:~0,4%-%date:~5,2%-%date:~8,2% %hour%:%minute%:%second%
echo %mtime%