473,396 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 6324
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 and this is a nice solution....
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 error SQL0181N The string representation of a...
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 requirements is that there should be no button that sets...
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 Element 'stylesheet' is not a known element. This can...
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 format? Example, User Defined Date Format as...
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 results for GMT+(Plus) time zones? // Format to...
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 & default users) Basically I have the following...
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 sends email using Winsock and works great. I am...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.