how to chnage date format from dd-MM-yy to MM-dd-yy in asp.net
I have date "22-12-2012"
i want to change into "12-22-2012"
when i try to convert it gives me error
String was not recognized as a valid DateTime.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Feb 5, 2013, 10:57 PM
I think this is duplicate quesion
http://www.c-sharpcorner.com/Forums/Thread/200801/change-date-from-22-12-2012-to-12-22-2012.aspx
Hemant SrivastavaPosted Feb 5, 2013, 6:01 PM
string originalDate = "22-12-2012";
string[] dateParts = originalDate.Split('-');
string convertedDate = dateParts[1] + "-" + dateParts[0] + "-" + dateParts[2];
Console.WriteLine(convertedDate);
Hemant SrivastavaPosted Feb 5, 2013, 1:46 PM