This is a discussion on How to convert a date to a globally accepted date format, in DOT NET 2005? within the C# Programming forums, part of the Software Development category; How to convert a date to a globally accepted date format, in DOT NET 2005?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| How to convert a date to a globally accepted date format, in DOT NET 2005? |
|
#2
| |||
| |||
| string myDateTimeValue = "2/16/1992 12:15:12"; DateTime myDateTime = DateTime.Parse (myDateTimeValue); Console.WriteLine ("1) myDateTime = {0}", myDateTime); // Reverse month and day to conform to a different culture. // the date is February 16, 1992, 12 hours, 15 minutes and 12 seconds. IFormatProvider culture = new CultureInfo ("fr-FR", true); string myDateTimeFrenchValue = " 16/02/1992 12:15:12"; DateTime myDateTimeFrench = DateTime.Parse myDateTimeFrenchValue, culture, DateTimeStyles.NoCurrentDateDefault); Console.WriteLine ("2) myDateTimeFrench = {0}",myDateTimeFrench); // the date is February 16, 1992, 12 hours, 15 minutes and 12 seconds. string[] expectedFormats = {"G", "g", "f" ,"F"}; myDateTimeFrench = DateTime.ParseExact (myDateTimeFrenchValue, expectedFormats, culture, DateTimeStyles.AllowWhiteSpaces); Console.WriteLine ("3) myDateTimeFrench = {0}", myDateTimeFrench); This example yields the following results: 1) myDateTime = 2/16/1992 12:15:12 PM 2) myDateTimeFrench = 2/16/1992 12:15:12 PM 3) myDateTimeFrench = 2/16/1992 12:15:12 PM |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Date format yymmdd | itbarota | HTML, CSS and Javascript Coding Techniques | 2 | 03-03-2008 08:07 PM |
| Convert a date in milliseconds back to a date string | itbarota | HTML, CSS and Javascript Coding Techniques | 2 | 03-03-2008 08:03 PM |
| Validate a date to be in the format dd/mm/yyyy | itbarota | HTML, CSS and Javascript Coding Techniques | 1 | 02-25-2008 08:21 PM |
| How can I show the documents last modified date in the format: month, date, year, tim | Pvinothkumar | HTML, CSS and Javascript Coding Techniques | 3 | 12-28-2007 04:58 AM |
| How do I format the Last-Modified date with javascript? | Pvinothkumar | HTML, CSS and Javascript Coding Techniques | 1 | 10-12-2007 10:17 PM |
Our Partners |