1.

Solve : plaese help time %time:~0,-6%?

Answer»

why does this come out with no 0 and just a SPACE i WANT it to be it the format 00:00 now it is like this ps _=space _2:24 for example please show me how to make this come out in a 00:00 format. example 02:24Quote

why does this come out with no 0 and just a space i want it to be it the format 00:00 now it is like this ps _=space _2:24 for example please show me how to make this come out in a 00:00 format. example 02:24

in my machine, when i do echo %time% , it is like this
18:45:48.76
so echo %time:~0,-6% gives me 18:45. It works alright for me.
i am not sure about your time settings. hope someone can help you with that.

One of the quirks with %time% is that all times before 10 AM contain a leading space. Using the KISS method might lead you to this solution.

Code: [Select]for /f "tokens=1-2 delims= " %%i in ('time /t') do echo %%i

Good luck. 8-)

Or try:

set t=%time: =0%
set t=%t:~0,5%
echo.%t%


Check to ensure that your Regional Time Setting is set to HH:MM:ss instead of h:mm:ss tt (or similar).
This negates the leading space space for HOURS of 1 thru 9.

Then if you do:
C:> echo %time:~0% [Enter]
23:34:07.51 {your current time}

-and-
C:> echo %time:~0,-3% [Enter]
23:36:36 {your current time}

-and-
C:> echo %time:~0,-6% [Enter]
23:33 {your current time}


Discussion

No Comment Found