tags:

views:

24

answers:

1

Hi

string date="8/13/2010"; // mm/dd/yyyy

System.Globalization.CultureInfo ci =System.Threading.Thread.CurrentThread.CurrentCulture;
 string CurrDateFormat = ci.DateTimeFormat.ShortDatePattern.ToString() -- **// dd/mm/yyyy**

DateTime dt=Convert.ToDateTime(date);  ***// Exception : In valid date time format***

date=dt.ToString(CurrDateFormat ,ci);

This is the code i written.

I want to display DateTime in UI as per the current Culture Date Time Format

Please help me how to solve the problem.

Thanks Kiran G

+2  A: 

You could use:

DateTime result;
DateTime.TryParse("8/13/2010", out result);

For error handling, you can put an if statement around the DateTime.TryParse method as this returns a boolean value.

Ardman