Now I don't really know exactly what the user was asking for, but I presume it is something fairly simple. The way that I would convert a UK date into a US date is as follows.
Read in the UK date, short format/long format whatever into a DateTime field. The output the date time using a US locale.
The following code works in vs2005.
CultureInfo cultEnGb = new CultureInfo("en-GB");
CultureInfo cultEnUs = new CultureInfo("en-US");
DateTime dtGb = Convert.ToDateTime(textBox1.Text, cultEnGb.DateTimeFormat);
textBox2.Text = dtGb.ToString(cultEnUs.DateTimeFormat.ShortDatePattern);
It reads in the date and tries to load the text as a UK Date from the first textbox and then it uses the US locale to output the string into the second textbox.
| Technorati Tags |
| datetime [feed], en gb [feed], tostring [feed], c# [feed], gb [feed], us [feed], localisation [feed], localization [feed] |
| My Related Documents |
| C#, .Net Framework: C# 3.0. Ugh!, C#, .Net Framework: Programming Windows Presentation Foundation (WPF), C#, .Net Framework: C# 3.0 and LINQ |
| Related Amazon Books |
| The Game Localization Handbook: (UK)/(USA), Internationalization and Localization Using Microsoft.NET: (UK)/(USA), A Practical Guide to Software Localization: For Translators, Engineers and Project Managers (Language International World Dictionary, V. 3): (UK)/(USA), Global Software: (UK)/(USA), A Practical Guide to Software Localization: For Translators, Engineers and Project Managers (Language International World Diretory, 3): (UK)/(USA), Programming for World Markets: A Guide to Software Internationalization: (UK)/(USA) |
| Related Images From Flickr |
![]() ![]() ![]() ![]() |











































































