title: MS-DOS timestamp in filename
body: <p>I have the following in a batch file.</p>
  
  <pre><code>set timefmt=%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%
  
  dir *.* &gt; logfile_%timefmt%.log
  </code></pre>
  
  <p>This works perfectly after 10am, but fails before hand because it adds a space to the timestamp instead of a leading 0.</p>
  
  <p>Is there a way in MS-DOS to create a time stamp with a leading 0?
  I'd prefer to use fairly standard commands so that it works from Windows XP onward.</p>