AM/PM not comes with other than US culture

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello All,<br/>
<br/>
I having a data table with a "OrderDate" column and Im formatting the date/time into 12 hrs format with AM/PM.<br/>
<br/>
In default (en-US) culture, the date comes perfectly with AM/PM, but AM/PM not comes with other culture (like french, etc...)..please help....<br/>
<br/>
foreach (DataRow dr in dtSortedData.Rows.Cast<DataRow>().Where(dr => dr.Table.Columns.Contains("OrderDate")))<br/>
{<br/>
dr["StrOrderDate"] = string.Format("{0:MM/dd/yyyy hh:mm:ss tt}", dr["OrderDate"]);<br/>
} <br/>
<br/>
I also using this...<br/>
<br/>
Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy"; <br/>
<br/>
Im trying to do this, but it gives me datetime to string conversion error,<br/>
<br/>
foreach (DataRow dr in dtSortedData.Rows.Cast<DataRow>().Where(dr => dr.Table.Columns.Contains("OrderDate")))<br/>
{<br/>
dr["StrOrderDate"] = DateTime.ParseExact((string)dr["OrderDate"], "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);<br/>
}

View the full article
 
Back
Top