Page 1 of 1

Show date in order I want it to

Posted: 12 Sep 2018 01:25
by hendrikbez
Hi

I have this code, that I got from the internet, but the date is in the wrong order, how can I change it to show DD/MMMM/YYYY.

Code: Select all

@echo off
set /p host=host Address: 
set logfile=Log_%host%.log

echo Target Host = %host% 
for /f "tokens=*" %%A in ('ping %host% -n 1 ') do (echo %%A && GOTO Ping)
:Ping
for /f "tokens=* skip=2" %%A in ('ping %host% -n 1 ') do (

    echo %date% %time:~0,2%:%time:~3,2%:%time:~6,2% %%A
    timeout 1 >NUL 
    GOTO Ping)

Re: Show date in order I want it to

Posted: 13 Sep 2018 09:26
by Aacini
Perhaps if you show us what is the output of your program we could have an idea of the point that should be fixed. "the date is in the wrong order" is not a description of the problem...

Re: Show date in order I want it to

Posted: 13 Sep 2018 10:50
by Squashman
If you want the date in a different order then substring the date variable just like you are doing with the time variable.

Re: Show date in order I want it to

Posted: 13 Sep 2018 10:53
by pieh-ejdsch
in this Forum you can Search for
timestamp

Phil

Re: Show date in order I want it to

Posted: 19 Sep 2018 02:17
by hendrikbez
Thank you, got it to work, thanks for the help and info