Tuesday, December 13, 2011

Convert to any Datetime format in c#

string StartDate = DateTime.Now.ToShortDateString();

string CStartDate = DateTime.ParseExact(CertStartDate, "dd/MM/yyyy",null).ToString("yyyy-MM-dd");


you can convert dd/MM/yyyy to any other format by specifiying like ToString("yyyy-MM-dd")

No comments:

Post a Comment