• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

Change Date Format programically

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
2 Solutions
Fahad MukhtarDistinguished EngineerCommented:
using System.Globalization;

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

Fahad MukhtarDistinguished EngineerCommented:
only your application will use this format now..dd/mm/yyyy

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

For example
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...

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Try this,

CultureInfo ci = new CultureInfo("en-GB",true);
ci.DateTimeFormat.ShortDatePattern = "dd/mm/yyyy";
Application.CurrentCulture = ci;
Fahad MukhtarDistinguished EngineerCommented:
shilpa2784 ,
why didnt you bothered to change the variable name from my code ? (myc to ci)

nghiaapAuthor Commented:
there are tons of ways,
thanks u very much
i'll try all of them
nghiaapAuthor Commented:
hi, rama_krishna580
do you mean that your solution for web application
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now