Printer Version Table of Contents Project Home Page
.EXAMPLE.....: 34 TIME_SET.BAT -- "time arithmetic" -- set TIME
.CATEGORY....: examples
.DISCUSSION..:
Advance the time by 3 hours, then set it back again

.CODE........:
@echo off
set Minutes=180
cls

FDATE /FF /Ofull /P"It is now "

:: get the absolute minutes now
Fdate /Ff /ominute# /vAbsMin

:: add a certain number of minutes
Fdate /f#add /a%AbsMin% /b%Minutes% /VNewMin

:: reset the time and date
Fdate /Ff /a%NewMin% /Iminute# /omm-dd-yy /vdate
Fdate /Ff /a%NewMin% /Iminute# /ohh:mm    /vtime
time %time%
date %date%

echo %Minutes% minutes added...
FDATE /FF /Ofull /P"It is now "

echo.
echo DOING SOME WORK ...
echo.

FDATE /FF /Ofull /P"It is now "

:: get the absolute minutes now
Fdate /Ff /ominute# /vAbsMin

:: subtract (add negative) a certain number of minutes
Fdate /f#add /a%AbsMin% /b-%Minutes% /VNewMin

:: reset the time and date
Fdate /Ff /a%NewMin% /Iminute# /omm-dd-yy /vdate
Fdate /Ff /a%NewMin% /Iminute# /ohh:mm    /vtime
time %time%
date %date%

echo %Minutes% minutes subtracted ...
FDATE /FF /Ofull /P"It is now "

set Minutes=
set AbsMin=
set NewMin=
set time=
set date=
echo.

:endit