Quote:You can retrieve the format strings from the CultureInfo DateTimeFormat property, which is a DateTimeFormatInfo instance. This in turn has properties like ShortDatePattern and ShortTimePattern, containing the format strings: CultureInfo us = new CultureInfo("en-US"); string shortUsDateFormatString = us.DateTimeFormat.ShortDatePattern; string shortUsTimeFormatString = us.DateTimeFormat.ShortTimePattern; CultureInfo uk = new CultureInfo("en-GB"); string shortUkDateFormatString = uk.DateTimeFormat.ShortDatePattern; string shortUkTimeFormatString = uk.DateTimeFormat.ShortTimePattern; If you simply want to format the date/time using the CultureInfo, pass it in as your IFormatter when converting the DateTime to a string, using the ToString method: string us = myDate.ToString(new CultureInfo("en-US")); string uk = myDate.ToString(new CultureInfo("en-GB"));
string dateAsString = "17/02/2016 02:31:09 a.m"; DateTime dt = DateTime.ParseExact(dateAsString.Replace(".m", "m"), "dd/MM/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.CurrentCulture);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)