469,117 Members | 1,316 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,117 developers. It's quick & easy.

How to get user's local date format

User can changes his/her local date setting, i.e., "M/d/yyyy", "dd/MMM/yyyy", .... etc. which interprets the date (string type) in the different way. for example "02/05/2004" can be the second of May or the fifth of Februry. So, it's neccessary to get the local date setting before display this date.

Any body knows
1. How to get the user's local date format o
2. How to enforce to use a standard date format for display the dat

Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US"
can enforce to use a region but can't get a specific date format define by users
Nov 20 '05 #1
2 6016
I found these codes

Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Intege
Private Const LOCALE_SSHORTDATE As Short = &H1Fs ' short date format strin
Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA"(ByVal Locale As Integer, ByVal LCType As Integer, ByVal lpLCData As String, ByVal cchData As Integer) As Intege

Public Sub Main(

Dim sReturn As Strin
Dim r As Intege
Dim LCID As Intege
LCID = GetSystemDefaultLCID(
r = GetLocaleInfo(LCID, LOCALE_SSHORTDATE, sReturn, Len(sReturn)

If r The
sReturn = Space(r
r = GetLocaleInfo(LCID, LOCALE_SSHORTDATE, sReturn, Len(sReturn)
MsgBox(Left(sReturn, r - 1)
End I
End Sub
Nov 20 '05 #2
"Li Pang" <an*******@discussions.microsoft.com> schrieb
User can changes his/her local date setting, i.e., "M/d/yyyy",
"dd/MMM/yyyy", .... etc. which interprets the date (string type) in
the different way. for example "02/05/2004" can be the second of May
or the fifth of Februry. So, it's neccessary to get the local date
setting before display this date.

Any body knows
1. How to get the user's local date format or
2. How to enforce to use a standard date format for display the
date

Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
can enforce to use a region but can't get a specific date format
define by users.


I'm not sure what's your intention. To convert from String to DateTime, you
can use DateTime.Parse, and optionally pass a Cultureinfo object to use
settings different from the current culture. Same for the other way, i.e.
DateTime.ToString.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by maflatoun | last post: by
1 post views Thread by Li Pang | last post: by
2 posts views Thread by Just4U | last post: by
2 posts views Thread by Dsperry101 via AccessMonster.com | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.