Using DateTimeFormatInfo

string strDate = “21-07-2006”; System.Globalization.DateTimeFormatInfo dtfi = new System.Globalization.DateTimeFormatInfo(); dtfi.ShortDatePattern = “dd-MM-yyyy”; dtfi.DateSeparator = “-“; DateTime objDate = Convert.ToDateTime(strDate, dtfi); Response.Write(objDate);IFormatProvider theCultureInfo = new System.Globalization.CultureInfo(“en-GB”, true);using ParseExactDateTime theDateTime = DateTime.ParseExact(“10-12-2006”, “mm-dd-yyyy”, theCultureInfo);Response.Write(theDateTime);using CultureInfo System.Globalization.CultureInfo cf = new System.Globalization.CultureInfo(“en-US”);DateTime dt = DateTime.Parse(“11-11-2005”, cf);string sdt = dt.ToString(cf);Response.Write(sdt);

Leave a Reply

Your email address will not be published. Required fields are marked *