Solved

Change Date Format programically

Posted on 2004-09-08
7
296 Views
Last Modified: 2009-04-02
how can i change date format from mm/dd/yyyy to dd/mm/yyyy programically
further more only my app use the new format (dd/mm/yyyy), all others still use the old one
0
Comment
Question by:nghiaap
7 Comments
 
LVL 19

Accepted Solution

by:
Desp earned 150 total points
ID: 12004491
using System.Globalization;

CultureInfo myc = new CultureInfo("en-GB",true);
myc.DateTimeFormat.ShortDatePattern = "dd/mm/yyyy";                  
Application.CurrentCulture = myc;

MessageBox.Show(DateTime.Now.ToShortDateString());
0
 
LVL 19

Expert Comment

by:Desp
ID: 12004497
only your application will use this format now..dd/mm/yyyy
0
 
LVL 23

Assisted Solution

by:rama_krishna580
rama_krishna580 earned 150 total points
ID: 12005742
Hi,

International Date and Time
You can use the session.lcid property to change the formatting of the date and time.

For example
<%session.lcid=2057%>
will set the date and time to UK format (DD/MM/YYYY instead of MM/DD/YYYY ) Here's a list of international locales. Bear in mind that setting these will also change currency formatting.

Locale ID (LCID) Description
1033 General Unicode
33280 Binary Order
1027 Catalan
197636 Chinese Bopomofo (Taiwan)
2052 Chinese Punctuation
133124 Chinese Stroke Count
1028 Chinese Stroke Count (Taiwan)
1050 Croatian
1029 Czech
1043 Dutch
1061  Estonian
1036 French
66615 Georgian Modern
1031 German
66567 German Phone Book
1038 Hungarian
66574 Hungarian Technical
1039 Icelandic
1040 Italian
1041 Japanese
66577 Japanese Unicode
1042 Korean
66578 Korean Unicode
1062 Latvian
1063 Lithuanian
1071  FYRO Macedonian
1044 Norwegian/Danish
1045 Polish
1046 Portuguese
1048 Romanian
1051 Slovak
1060 Slovenian
1034 Spanish (Traditional)
3082 Spanish (Spain)
1053 Swedish/Finnish
1054 Thai
2057 UK English
1058  Ukrainian
1066 Vietnamese  

best of luck...

R.K
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:shilpa2784
ID: 12024893
Try this,

CultureInfo ci = new CultureInfo("en-GB",true);
ci.DateTimeFormat.ShortDatePattern = "dd/mm/yyyy";
Application.CurrentCulture = ci;
0
 
LVL 19

Expert Comment

by:Desp
ID: 12025484
shilpa2784 ,
why didnt you bothered to change the variable name from my code ? (myc to ci)


0
 
LVL 1

Author Comment

by:nghiaap
ID: 12032452
wa
there are tons of ways,
thanks u very much
i'll try all of them
0
 
LVL 1

Author Comment

by:nghiaap
ID: 12041086
hi, rama_krishna580
do you mean that your solution for web application
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now