convert date time to english ( us )

I have a login script that is grabbing some user information along with the date and writing the info to a text file

Previosuly I asked a question about how to convert a date from different formats like
3.29.05 or 3/29/2005 to this format 03/29/2005  ( http:Q_21368889.html )

Now I realize that some users have changed their date/time settings to output a time having the month first e.g. 31.3.2005

How can I get their date to be like the others from my script?
I do not want to change their settings

is there anything like...

if date-time/format does not equal english ( US) then
convert the given date-time to english us

I'm using vbscript right now but can put this in a vb app if I need to.
I will be getting the current date/time and placing it into a text file.

Thank you for your time.
If this was not enough info let me know and I will post whatever is needed
LVL 16
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Using the Format function along with named date formats will output the date in the system's default format:


MsgBox Format(Now, "Short Date")

mdiglioAuthor Commented:
Hi Erick,
Thank you for your response.

The problem I have is that I dont want to use the system's default format.
Some users have it setup differently and in different regional settings like English ( Australia )
which gives me a date that has the month first

I am outputting the date and time to a text file and would like them to all be the same in this text file

Is there any way I can query the system and return the regional options ?
You can get the current user's settings like this:

' Modified from a sample found here:

Option Explicit

Private Const DATE_LONGDATE As Long = &H2
Private Const DATE_SHORTDATE As Long = &H1
Private Const LOCALE_SLANGUAGE As Long = &H2 'localized name of language
Private Const LOCALE_SSHORTDATE As Long = &H1F 'short date format string
Private Const LOCALE_SLONGDATE As Long = &H20 'long date format string

Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Private Declare Function GetUserDefaultLCID Lib "kernel32" () As Long

Private Declare Function GetLocaleInfo Lib "kernel32" _
   Alias "GetLocaleInfoA" _
  (ByVal Locale As Long, _
   ByVal LCType As Long, _
   ByVal lpLCData As String, _
   ByVal cchData As Long) As Long

Private Function GetUserLocaleInfo(ByVal dwLocaleID As Long, ByVal dwLCType As Long) As String

    Dim sReturn As String
    Dim r As Long
    sReturn = Space$(1024)
    'call the function passing the Locale type
    r = GetLocaleInfo(dwLocaleID, dwLCType, sReturn, Len(sReturn))
    'if successful..
    If r Then
        'r contains number of characters copied + null terminator
        GetUserLocaleInfo = Left$(sReturn, r - 1)
    End If
End Function

Private Sub Command1_Click()
    Dim LCID As Long
    'get the Location ID
    LCID = GetUserDefaultLCID()
    'get the short date format
    MsgBox GetUserLocaleInfo(LCID, LOCALE_SSHORTDATE)

End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

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.