Solutions 1:
String to Date
DateTime Date = Convert.ToDateTime("1/22/2013 12:37:45 PM");
Date to String
MessageBox.Show(Date.ToString("d")); // 1/22/2013
MessageBox.Show(Date.ToString("D")); // Tuesday, January 22, 2013
MessageBox.Show(Date.ToString("U")); // Tuesday, January 22, 2013 12:37:45 PM
MessageBox.Show(Date.ToString("y")); // January, 2013
MessageBox.Show(String.Format("{0:ddd}",Date)); //Tue
MessageBox.Show(String.Format("{0:MM/dd/yyyy}",Date)); // 01/22/2013
String Format for DateTime [C#]
No comments:
Post a Comment