I am running a batch script to retrieve information from a device. Tieing this up with a separate log file requires accuracy greater than the minute accuracy I can get using time /t.

This question has a method I wasn't aware of using wmic, but that only allows access to time up to 1 second accuracy (technically, you can ask for milliseconds - but the answer is always NULL).

  • 3
    Even though the command prompt is "aka DOS", it is not DOS. – user1686 Oct 26 '11 at 17:12

I had forgotten that the command prompt has some built in variables.

Use %TIME%

set dt=%DATE%-%TIME%
echo %dt%

gives 26/10/2011-15:08:19.09

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.