1.

Solve : future time saving?

Answer»

Hello,
how can i save the time that will be NEXT hour in a variable?

i MEAN if it's 3:40 now i want it to save 4:40 auto.

thxgosh i gotta stop being lazy and read the long explanations on commands such as set XD

thanks! and btw the 7th line should be set HH=%cktime:~0,2% in case it's 10 or 12


is there a way to transfer the output of the command time /t directly into the set command without using a text file?Batch code is not DESIGNED for date/time arithmetic. Numbers like 08 and 09 are seen as octal not decimal and hour+1 at the noon/midnight hour produce results that may not be accurate for your localized settings.

I'm not a big fan of hybrid batch files because of the hoops you have to jump thru for all the special characters used in batch code. In any case, this little piece of doggerel may help.

Code: [Select]@echo off

::
:: Create VBS script
::
(
echo newTime = DateAdd("h", 1, Time^)
echo WScript.Echo newTime
) > .\newTime.vbs

::
:: Execute script & grab the time
::
for /f "delims=" %%i in ('cscript newTime.vbs') do set newTime=%%i
echo %newTime%
del .\newTime.vbs

If need be, you can further parse the newTime variable for your purposes.

Good luck.

Just noticed that a question about time arithmetic was first responded to by a poster name TimeKeeper. What are the odds?
Quote from: Sidewinder on April 26, 2011, 06:46:27 AM

Just noticed that a question about time arithmetic was first responded to by a poster name TimeKeeper. What are the odds?

Considering that was really Billrich, who needs to craft a new fake name every time he posts, this is not much of a coincidence.


Discussion

No Comment Found