• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2018
  • Last Modified:

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?
0
jl66
Asked:
jl66
  • 2
1 Solution
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
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?
0
 
jl66Author Commented:
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).
0
 
AmazingTechCommented:
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

0
 
AmazingTechCommented:
Opps the for needs to be on 1 line.
@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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now