1

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.

AnthonyKnaup
  • 19
  • 1
  • 3
  • Do you know that format of time output by `time /T` as well as when using `echo %TIME%` depends on Windows region and language settings specified for the current user account. If your batch file should output the time always in same format, you need the command `%SystemRoot%\System32\wbem\wmic.exe OS get localdatetime` and extra code to output the time in the format you want independent on region and language settings. – Mofi Jul 28 '16 at 18:18
  • i just did this: for /f "delims=" %%a in ('time /T') do @set foobar=%%a echo The Time Is: = %foobar% – AnthonyKnaup Jul 28 '16 at 19:13

5 Answers5

2

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

 @echo off
 set /p ".=The time is = "<nul &TIME /T
 pause
Squashman
  • 13,649
  • 5
  • 27
  • 36
0

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.

Community
  • 1
  • 1
i_am_jorf
  • 53,608
  • 15
  • 131
  • 222
0

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%
AnthonyKnaup
  • 19
  • 1
  • 3
0
ECHO The time is %time:~0,2%:%time:~3,2%:%time:~6,2%

will give you:

The time is 14:59:02
Rawns
  • 865
  • 4
  • 27
0

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