472,352 Members | 1,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,352 software developers and data experts.

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 6185
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: F | last post by:
Hi I have posted the question few days back about problem in inserting the dates in SQL server and thankful to them who replied. That was solved...
2
by: Tatiana Zadiraka | last post by:
I use DB2 8.1 with FixPack 5. In command line for sql I get all DATE columns only in MM-DD-YYYY format. Of course, DATE('20-12-2003') gives me an...
1
by: panche | last post by:
I'm developing a fairly simple user control that has two textboxes for date/time entry (a from date/time and a to date/time). One of my...
1
by: Robert | last post by:
I have a large web site converted from 1.1 to 2.0 and in VS 2005, the IDE complains that in the ASPX file (html source): Error 1 ...
1
by: abcabcabc | last post by:
I write an application which can let user define own date format to input, How to convert the date string to date value with end-user defined date...
13
by: maflatoun | last post by:
Hi, I have the following function to convert UTC time to Local time. It works perfect for GMT- (Minus) time zones however it provides incorrect...
1
by: Li Pang | last post by:
Hi, I'd like to get the local language setting used to interpret the date string in Excel, anyone has an idea? Thanks in advance
2
by: Just4U | last post by:
Hello, I take an old post because, nobody seem to answer my problem. Config: Windows 2003 x64 (US) + sp2 Regional settings : French (for all &...
2
by: Dsperry101 via AccessMonster.com | last post by:
Hello, I have been working with visual basic for a while but this is something I have never understood. I have some code in a VB6 application that...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.