Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Change Date Format programically

Posted on 2004-09-08
7
310 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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