How to get the Date in a batch file in a predictable format?
- by AngryHacker
In a batch file I need to extract a month, day, year from the date command. So I used the following, which essentially parses the Date command to extract its sub strings into a variable:
set Day=%Date:~3,2%
set Mth=%Date:~0,2%
set Yr=%Date:~6,4%
This is all great, but if I deploy this batch file to a machine with a different regional/country settings, it fails because month, day and year are in different locations.
How can I extract month, day and year regardless of the date format?