Can I make the DOS time command return the time with seconds showing?

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
I have a batch file that writes out to a file, and I use the TIME command to add a timestamp

time /T>> C:\results.txt

but it only gives hour and minute. Can I get the "time" command to give me seconds, or even (hope, hope) milliseconds?
 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
unfortunately the formatting seems to apply only to the user input at the prompt.

What I actually need now is some way to program DOS to do an "ENTER" keystroke. I've looked around on google for a while, but no luck so far
 

Felecha

Golden Member
Sep 24, 2000
1,434
0
0
I found that if you do

time >> C:\results.txt

you get the time in detail, with a prompt for the new time

The current time is: 7:07:47.65
Enter the new time:

At a command prompt you can then either enter a time or hit "Enter" which leaves the time unchanged and you move on. But this is a batch file ...

The trick I found is to do

echo.|time >> C:\results.txt

which evidently pipes an "Enter" to the time command, which then lets you move on INSIDE the batch file, and also gives the detailed time in the results file. It has the extra text, but hey, I can at least read the detailed time of the command which is all I really care about
 

TechnoPro

Golden Member
Jul 10, 2003
1,727
0
76
You were getting close. The following will append the detailed time to a file of your choice:

echo %time% >> C:\results.txt

Enjoy.