Get current date in format YYYYMMDD

/ Published in: DOS Batch
Save to your folder(s)

The code works if and only if your system is using English(United States) date format (i.e. "Web 05/11/2011").
If your systems is using English(United Kingdom) date format just replace %%B in the first and third rows with %%A.

Copy this code and paste it in your HTML
  1. for /F "tokens=1* delims= " %%A in ('date /T') do set CDATE=%%B
  2. for /F "tokens=1,2 eol=/ delims=/ " %%A in ('date /T') do set mm=%%B
  3. for /F "tokens=1,2 delims=/ eol=/" %%A in ('echo %CDATE%') do set dd=%%B
  4. for /F "tokens=2,3 delims=/ " %%A in ('echo %CDATE%') do set yyyy=%%B
  5. set date=%yyyy%%mm%%dd%

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.