IT Community - Software Programming, Web Development and Technical Support

How to convert a date to a globally accepted date format, in DOT NET 2005?

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?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 07-25-2007, 03:20 AM
Archer Archer is offline
D-Web Programmer
 
Join Date: Jun 2007
Posts: 52
Archer is on a distinguished road
Question How to convert a date to a globally accepted date format, in DOT NET 2005?

How to convert a date to a globally accepted date format, in DOT NET 2005?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-25-2007, 03:21 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: How to convert a date to a globally accepted date format, in DOT NET 2005?

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/c-programming/2701-how-convert-date-globally-accepted-date-format-dot-net-2005-a.html
Posted By For Type Date
How to convert a date to a globally accepted date format, in DOT ... | Web Hosting This thread Refback 03-27-2008 09:52 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date format yymmdd itbarota HTML, CSS and Javascript Coding Techniques 2 03-03-2008 09:07 PM
Convert a date in milliseconds back to a date string itbarota HTML, CSS and Javascript Coding Techniques 2 03-03-2008 09:03 PM
Validate a date to be in the format dd/mm/yyyy itbarota HTML, CSS and Javascript Coding Techniques 1 02-25-2008 09: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 05:58 AM
How do I format the Last-Modified date with javascript? Pvinothkumar HTML, CSS and Javascript Coding Techniques 1 10-12-2007 11:17 PM


All times are GMT -7. The time now is 08:37 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0