简体   繁体   中英

is this possible? “ECHO. The time is: %time /T%”

I have a stats.bat program that will refresh in order to show me the most up to date data that I can have.

I have tried just about ever thing to my knowledge.

In the script I have I want it to show time but I want it to something like this.

ECHO The Time Is: %time /T%

Where the "%time /T%" will show the time on the same line as the ECHO line.

I have tried researching on it but I just cant find anything on the subject.

Just a neat little trick using SET /P with nul redirection.

 @echo off
 set /p ".=The time is = "<nul &TIME /T
 pause

Try something like this:

for /f "delims=" %%a in ('time /T') do @set foobar=%%a
echo The Time Is: = %foobar%

For further discussion, see this question .

I got it too work guys if you want to see what i was doing dm me. also this was the code i used thanks to "i_am_jorf"

for /f "delims=" %%a in ('time /T') do @set foobar=%%a
echo The Time Is: = %foobar%
ECHO The time is %time:~0,2%:%time:~3,2%:%time:~6,2%

会给你:

The time is 14:59:02

I was using this cmd

for /F "tokens=1" %%i in ('time /t') do set mytime=%%i

echo "time is = " %mytime:~0,2%%time:~3,2%%time:~6%

the result is: time is = 094752.78

instead, echo %time%

9:47:52.78

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM