dd:mm:yyyy hh:mm:ss
mm:dd:yyyy
IFormatProvider
System.Globalizationsystem
string myDate = "15:06:2010"; DateTime dt; //verify given date is valid or not if (DateTime.TryParseExact(myDate, "dd:MM:yyyy", CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dt)) { //Valid date format MessageBox.Show(dt.ToString("MM:dd:yyyy")); } else { //invalid date format }
DateTime dt = DateTime.Now; string Str = dt.ToString("mm:dd:yyyy");
var dt = DateTime.UtcNow.ToString("dd:MM:yyyy hh:mm:ss"); // Date to string var nDt = DateTime.ParseExact(dt, "dd:MM:yyyy hh:mm:ss", CultureInfo.InvariantCulture); // String to datetime var sdt = nDt.ToString("MM:dd:yyyy"); // Back to formatted string
System.Globalization.DateTimeFormatInfo dateInfo = new System.Globalization.DateTimeFormatInfo(); dateInfo.ShortDatePattern = "dd/MM/yyyy";//i am getting date in this format DateTime temp; string toDate = txtToDate.Text; temp = Convert.ToDateTime(toDate, dateInfo); toDate = temp.ToString("MM/dd/yyyy").Trim();//converting dd/MM/yyyy to MM/dd/yyyy
string stDate=string.format(DateTime.Now,"{0:dd/MM/yyyy}");
string dt= string.Format("{0:MM-dd-yyyy}", DateTime.Now.Date);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)