. Topicala Page Index Token

A Journal about the experiences I have developing little applications in C#, Perl, Html and Javascript and talking about things new things that I use. Always Geeky; Always Nerdy; Always poor Grammer!

I am a Software Analyst Developer working in Southport, England but living in Liverpool. I develop mainly in C# and ASP.Net. I have been developing comercial software for several years now. I maintain this site (hosted at SwitchMedia UK) as a way of exploring new technologies (such as AJAX) and just generally talking about techie geek issues. This site is developed through a host of Perl scripts and a liberal use of Javascript. I enjoy experimenting with new technologies and anything that I make I host here.

Quick Search

Web www.kinlan.co.uk

Tuesday, November 29, 2005

Google Search: c# convert date from uk to usa

One of the searches that came from Google to my site asked the following "c# convert date from uk to usa".

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
[feed], [feed], [feed], [feed], [feed], [feed], [feed], [feed]

Related Wikipedia Documents
, , , , , , ,

My Related Documents
, ,

Related Amazon Books
The Game Localization Handbook: /, Internationalization and Localization Using Microsoft.NET: /, A Practical Guide to Software Localization: For Translators, Engineers and Project Managers (Language International World Dictionary, V. 3): /, Global Software: /, A Practical Guide to Software Localization: For Translators, Engineers and Project Managers (Language International World Diretory, 3): /, Programming for World Markets: A Guide to Software Internationalization: /

Related Images From Flickr

Comments: [Add New]

Thanks for the info mate. Very helpful

By Anonymous Anonymous, at Thursday, April 23, 2009 11:34:00 AM