473,699 Members | 2,488 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.CurrentT hread.CurrentCu lture = 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 6343
I found these codes

Private Declare Function GetSystemDefaul tLCID Lib "kernel32" () As Intege
Private Const LOCALE_SSHORTDA TE 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 = GetSystemDefaul tLCID(
r = GetLocaleInfo(L CID, LOCALE_SSHORTDA TE, sReturn, Len(sReturn)

If r The
sReturn = Space(r
r = GetLocaleInfo(L CID, LOCALE_SSHORTDA TE, sReturn, Len(sReturn)
MsgBox(Left(sRe turn, r - 1)
End I
End Sub
Nov 20 '05 #2
"Li Pang" <an*******@disc ussions.microso ft.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.CurrentT hread.CurrentCu lture = 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.ToStri ng.
--
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
2408
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. http://www.aspfaq.com/show.asp?id=2023 Now I am facing another problem. I have to get data between two dates. That dates user has to provide and in
2
6965
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 datetime value is out of range. SQLSTATE=22007 My db config is: Database territory = RU
1
2892
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 these values (i.e., no button to cause a postback). The problem I'm having is that I need a number of validations to be performed on the data entry, but I don't know how to do this without having the user control/page posted back to the server. ...
1
2004
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 occur if there is a compilation error in the Web site. C:\Documents and Settings\...\Local Settings\Temp\1\VWDWebCache\onlineformsdev.....com\sweepv2\dorequest1.aspx 16 7 http://onlineformsdev.....com/ The source code (start of the...
1
4603
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 "dd/MM/yyyy" input as "01082003" convert to date value as, 01 Aug 2003 Example, User Defined Date Format as "yyyy,dd,MM"
13
16168
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 local time from UTC function formatToLocalTimeDate(inDate) { var today = new Date(); var inDateMod = new Date(inDate);
1
1232
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
7775
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 code on my server
2
642
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 trying to incorporate the code in Access 2000 . I inserted the activex control "Microsoft Winsock control (SP6) and it shows up on the form. When I ran the form I get "object variable with block not set" on the line "Winsock1.LocalPort = 0", I...
0
8687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9174
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9034
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8883
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7750
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5874
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.