How to get the Date in a batch file in a predictable format?
Posted
by
AngryHacker
on Super User
See other posts from Super User
or by AngryHacker
Published on 2011-07-27T22:38:53Z
Indexed on
2014/08/20
4:24 UTC
Read the original article
Hit count: 163
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?
© Super User or respective owner