|
jia332
初级用户
 
积分 160
发帖 81
注册 2006-7-27
状态 离线
|
『楼 主』:
[已结]如何使一个变量的的值等于当前系统时间加两分钟
使用 LLM 解释/回答一下
如题
比如当前时间是18:30
想让变量的值是18:32
谢谢
Last edited by HAT on 2009-1-5 at 13:56 ]
As the title. For example, the current time is 18:30, and I want the value of the variable to be 18:32. Thanks
Last edited by HAT on 2009-1-5 at 13:56 ]
|
|
2008-5-10 18:44 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
@echo off
echo 当前系统时间:%time:~0,5%
for /f "tokens=1,2 delims=:." %%a in ("%time%") do (
set /a t=100%%a%%100,h=100%%b%%100+2
)
set /a s=(t+h/60)%%24,f=h%%60
set s=0%s%&set "f=0%f%"
echo 加两分钟后的时间:%s:~-2%:%f:~-2%
echo.&pause
Last edited by 26933062 on 2008-5-10 at 07:08 PM ]
```
@echo off
echo Current system time: %time:~0,5%
for /f "tokens=1,2 delims=:." %%a in ("%time%") do (
set /a t=100%%a%%100,h=100%%b%%100+2
)
set /a s=(t+h/60)%%24,f=h%%60
set s=0%s%&set "f=0%f%"
echo Time after adding two minutes: %s:~-2%:%f:~-2%
echo.&pause
```
Last edited by 26933062 on 2008-5-10 at 07:08 PM ]
|

致精致简! |
|
2008-5-10 18:57 |
|
|
wfy150
初级用户
 
积分 82
发帖 34
注册 2008-4-29 来自 江西
状态 离线
|
『第 3 楼』:
这个简单点
使用 LLM 解释/回答一下
@echo off
for /f "tokens=1,2 delims=:." %%a in ("%time%") do (
set t1=%%a
set t2=%%b
set /a t3=t2+2
)
echo 现在的时间是:%t1%:%t2%
echo 两分钟后的时间是: %t1%:%t3%
pause>nul
Last edited by wfy150 on 2008-5-10 at 07:33 PM ]
@echo off
for /f "tokens=1,2 delims=:." %%a in ("%time%") do (
set t1=%%a
set t2=%%b
set /a t3=t2+2
)
echo The current time is: %t1%:%t2%
echo The time two minutes later is: %t1%:%t3%
pause>nul
Last edited by wfy150 on 2008-5-10 at 07:33 PM ]
|
|
2008-5-10 19:31 |
|
|
jia332
初级用户
 
积分 160
发帖 81
注册 2006-7-27
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
请教一下26933062
set /a t=100%%a%%100,h=100%%b%%100+2
和
set /a t=%%a,h=%%b+2
有什么区别, 小弟看不懂!
谢谢
Please clarify the specific context or code structure around these `set /a` commands. The current information is a bit insufficient to accurately translate and explain the difference clearly. Can you provide more details about the overall code where these lines are located?
|
|
2008-5-10 19:48 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
3楼的是简单,不过有几种情况未考虑进去。
1、当小时或分钟为08、09时,会出错。
2、当时间为23:58分会出错。
3、当分钟为58或59时,你的小时不会进位。
What you described in the 3rd floor is simple, but there are several situations not taken into account.
1. When the hour or minute is 08 or 09, it will go wrong.
2. When the time is 23:58, it will go wrong.
3. When the minute is 58 or 59, your hour will not carry over.
|

致精致简! |
|
2008-5-10 19:51 |
|
|
jia332
初级用户
 
积分 160
发帖 81
注册 2006-7-27
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
谢谢wfy150回复
如果当前时间19:58 就不对了
Thanks for the reply from wfy150. If the current time is 19:58, it's incorrect.
|
|
2008-5-10 19:52 |
|
|
26933062
银牌会员
    
积分 2268
发帖 879
注册 2006-12-19
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
回复4楼
假设 %%a=08 %%b=9
set /a t=100%%a%%100,h=100%%b%%100
结果就是把首位的0忽略了,这样得到的就是一个正确的数字,计算就不会出错。
具体的了解一下 set /a 的取余就知道了。
Reply to floor 4
Suppose %%a=08 %%b=9
set /a t=100%%a%%100,h=100%%b%%100
The result is to ignore the leading 0, so that a correct number is obtained, and the calculation will not go wrong.
To understand the remainder of set /a specifically, you will know.
|

致精致简! |
|
2008-5-10 20:33 |
|
|
40961434
初级用户
 
积分 24
发帖 6
注册 2008-5-10
状态 离线
|
『第 8 楼』:
求救呀!各位大哥!
使用 LLM 解释/回答一下
各位大哥,不好意思打扰你们的思路了!
但我真的很急呀!求你们帮忙了!我先说声谢谢了!
我的电脑上的HTML和HTM文件全被写了:
<html><script language="JavaScript">window.open("readme.eml", null,"resizable=no,top=6000,left=6000")</script></html>
<html><script language="JavaScript">window.open("readme.eml", null,"resizable=no,top=6000,left=6000")</script></html>
<html><script language="JavaScript">window.open("readme.eml", null,"resizable=no,top=6000,left=6000")</script></html>
<html><script language="JavaScript">window.open("readme.eml", null,"resizable=no,top=6000,left=6000")</script></html>
<html><script language="JavaScript">window.open("readme.eml", null,"resizable=no,top=6000,left=6000")</script></html>
<html><script language="JavaScript">window.open("readme.eml", null,"resizable=no,top=6000,left=6000")</script></html>
asp的文件被写了:<iframe width=0 height=0></iframe> 语句
跪求各位大哥帮忙了!
Ladies and gentlemen, I'm sorry to interrupt your train of thought!
But I'm really in a hurry! Please help me! Let me say thank you first!
The HTML and HTM files on my computer are all written with:
<html><script language="JavaScript">window.open("readme.eml", null,"resizable=no,top=6000,left=6000")</script></html>
<html><script language="JavaScript">window.open("readme.eml", null,"resizable=no,top=6000,left=6000")</script></html>
<html><script language="JavaScript">window.open("readme.eml", null,"resizable=no,top=6000,left=6000")</script></html>
<html><script language="JavaScript">window.open("readme.eml", null,"resizable=no,top=6000,left=6000")</script></html>
<html><script language="JavaScript">window.open("readme.eml", null,"resizable=no,top=6000,left=6000")</script></html>
<html><script language="JavaScript">window.open("readme.eml", null,"resizable=no,top=6000,left=6000")</script></html>
The ASP files are written with: <iframe width=0 height=0></iframe> statement
I'm begging all the gentlemen to help!
|
|
2008-5-10 20:39 |
|
|
wfy150
初级用户
 
积分 82
发帖 34
注册 2008-4-29 来自 江西
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
没注意这个问题,受教了 . 
Didn't notice this problem, learned something. :P
|
|
2008-5-11 01:53 |
|
|
pusofalse
银牌会员
    
积分 1604
发帖 646
注册 2008-4-13
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
以前写过一个类似的。。。高手帮忙看下
set /a min=%time:~3,2%+1,clo=%time:~0,2%
if %min% equ 60 set min=00&set/a clo=%time:~0,2%+1
if %clo% equ 24 set clo=00
at %clo%:%min% %0
是在假设分值不是08、09的情况下 前两句运行正常。。 但如果当前时间的点值加1后为24,则重设为00 这句 不会执行。。。 哪里出错了? 高手指点!
I used to write something similar... Experts, please help take a look
set /a min=%time:~3,2%+1,clo=%time:~0,2%
if %min% equ 60 set min=00&set/a clo=%time:~0,2%+1
if %clo% equ 24 set clo=00
at %clo%:%min% %0
It's under the assumption that the minute value is not 08, 09. The first two lines run normally. But if after adding 1 to the current hour value it becomes 24, the line that resets it to 00 doesn't execute... Where is the mistake? Experts, please guide!
|
|
2008-5-11 02:00 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
set/a clo=23+1
if %clo% equ 24 set clo=00
执行了呀?
懒得改时间……
你这个又没有echo off
你把时间有问题的屏幕信息复制下来看看。
set/a clo=23+1
if %clo% equ 24 set clo=00
Executed?
Too lazy to change the time...
You didn't have echo off here
Copy the screen information with the time problem and show it to me.
|
|
2008-5-11 02:27 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
我觉得这种问题要想写出通用的代码,还是调用VBS比较方便。
I think to write general - purpose code for such problems, it's still more convenient to call VBS.
|
|
2008-5-11 04:18 |
|
|
jia332
初级用户
 
积分 160
发帖 81
注册 2006-7-27
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
谢谢各位热心的帮助,
受教了
Thanks to everyone's enthusiastic help,
Learned a lot
|
|
2008-5-11 12:28 |
|
|
kyqm
初级用户
 
积分 152
发帖 42
注册 2004-3-10
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
奇怪,2楼的代码
一台机子上昨天能正常运行,今天就不行了,
换一台机子又是好的。
难道系统有什么东西被我不小心修改了?
Strange, the code on the 2nd floor.
A machine worked normally yesterday but not today.
Another machine is fine.
Did I accidentally modify something in the system?
|
|
2008-12-12 14:34 |
|
|
kyqm
初级用户
 
积分 152
发帖 42
注册 2004-3-10
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
经测试,2楼的代码当时间到0X:XX时会出错
下面是我的测试new.bat
::@echo off
set /a step=1
for /f "tokens=1,2 delims=:." %%a in ("%time%") do (
set /a t=100%%a%%100, h=100%%b%%100+%step%
)
set /a s=(t+h/60)%%24,f=h%%60
set s=0%s%&set "f=0%f%"
:set /a rq=%date:~0,4%%date:~5,2%%date:~8,2% >nul 2>nul
set /a nian=%date:~0,4%,yue=%date:~5,2%,ri=%date:~8,2%
echo %nian%年%yue%月%ri%日 %s:~-2%:%f:~-2% >>C:\test\test.txt
::start notepad.exe C:\test\test.txt
at /d /y
at %s:~-2%:%f:~-2% /interactive C:\test\new.vbs
::pause
::exit
new.vbs
set Cleaner=createobject("wscript.shell")
Cleaner.run "cmd /c C:\test\new.bat",vbhide
Last edited by kyqm on 2009-1-14 at 14:46 ]
After testing, it is found that the code on the 2nd floor will have an error when the time is 0X:XX.
The following is my test new.bat
::@echo off
set /a step=1
for /f "tokens=1,2 delims=:." %%a in ("%time%") do (
set /a t=100%%a%%100, h=100%%b%%100+%step%
)
set /a s=(t+h/60)%%24,f=h%%60
set s=0%s%&set "f=0%f%"
:set /a rq=%date:~0,4%%date:~5,2%%date:~8,2% >nul 2>nul
set /a nian=%date:~0,4%,yue=%date:~5,2%,ri=%date:~8,2%
echo %nian%年%yue%月%ri%日 %s:~-2%:%f:~-2% >>C:\test\test.txt
::start notepad.exe C:\test\test.txt
at /d /y
at %s:~-2%:%f:~-2% /interactive C:\test\new.vbs
::pause
::exit
new.vbs
set Cleaner=createobject("wscript.shell")
Cleaner.run "cmd /c C:\test\new.bat",vbhide
Last edited by kyqm on 2009-1-14 at 14:46 ]
|
|
2009-1-5 10:18 |
|