Link to home
Start Free TrialLog in
Avatar of jl66
jl66Flag for United States of America

asked on

How to get Short date and Long date format with DOS shell code

From Start->Settings->Control panel->Regional and Language Options, we can get the Short Date and Long date as wellas the other info. How to programmatically get the info out with DOS shell commands or the other programming languages?
Avatar of Qlemo
Qlemo
Flag of Germany image

You do not have access to the locale data in DOS. You have to use e.g. PowerShell or WSH for this.
Do you want the date formatted, or only the format itself?
Avatar of jl66

ASKER

Thanks for reply. What I really want is to get what in the drop-down bpx (For example, English (United States) ) and get the Short date out (4/27/2009).
Avatar of AmazingTech
AmazingTech

Here's a batch file that uses REG to extract what is setup in the registry. You can convert ENU to English (United States) but you'll need to figure out the 3 letters for each code.
@ECHO OFF
Set sShortDate=
Set sLanguage=
for /f "tokens=2,*" %%a in ('reg query "hkcu\control panel\international" ^|
find /i "sshortdate"') do Set sShortDate=%%b
for /f "tokens=2,*" %%a in ('reg query "hkcu\control panel\international" ^|
find /i "slanguage"') do Set sLanguage=%%b
 
ECHO Short date is %sShortDate%
ECHO Language is %sLanguage%

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of AmazingTech
AmazingTech

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial