How can get the ISO format date placed into an environment variable regardless of regional settings? Answers to related questions here suggest this will require a special .exe, so a source of that would be appreciated.


See this post. Accepted answer suggests a way to get ISO format date:

If you want the date independently of the region day/month order, you can use "WMIC os GET LocalDateTime" as a source, since it's in ISO order:

@echo off
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
set ldt=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2% %ldt:~8,2%:%ldt:~10,2%:%ldt:~12,6%
echo Local date is [%ldt%]


Local date is [2012-06-19 10:23:47.048]

  • Thanks. That gave date and time but was easy to amend to give just date. – ChrisJJ Apr 8 '14 at 22:55

You can use:

date /t

to view the date, but I'm not sure if this is the format you're after. The same output will also be available as %date%


echo %date%

would work as well.

This is what the output would look like in both cases:

di 08-04-2014

This is what cmd can offer you without any external program.

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.