I've been compiling a batch file that echos the date according to the following format: YYYY-MM-DD. I have successfully worked it out, and it works fine on my computer; However, when I run the file on a different PC, my code will not get the date properly.
After investigation, I concluded that the problem is in the date format set on each PC. While on my computer the date format is MM-DD-YYYY on the other computer the date is DD-MM-YYYY.
So my question is, what should I do in a batch file so that whenever I want to retrieve a date through %date% it would follow a certain format in order for me to be able to select the days and months in a standard way. In fewer words, how can I make the code compatible with whatever computer no matter what the selected date format is on it.
Question
okayokay
Hello
I've been compiling a batch file that echos the date according to the following format: YYYY-MM-DD. I have successfully worked it out, and it works fine on my computer; However, when I run the file on a different PC, my code will not get the date properly.
After investigation, I concluded that the problem is in the date format set on each PC. While on my computer the date format is MM-DD-YYYY on the other computer the date is DD-MM-YYYY.
So my question is, what should I do in a batch file so that whenever I want to retrieve a date through %date% it would follow a certain format in order for me to be able to select the days and months in a standard way. In fewer words, how can I make the code compatible with whatever computer no matter what the selected date format is on it.
My code
Thank you..
Link to comment
Share on other sites
6 answers to this question
Recommended Posts