I need to change format of
this.TextBox3.Text = DateTime.Now.ToShortDateString();
so it returns (for example) 25.02.2012, but I need 02.25.2012
25.02.2012
02.25.2012
How can this be done?
Use DateTime.ToString with the specified format MM.dd.yyyy:
DateTime.ToString
MM.dd.yyyy
this.TextBox3.Text = DateTime.Now.ToString("MM.dd.yyyy");
Here, MM means the month from 01 to 12, dd means the day from 01 to 31 and yyyy means the year as a four-digit number.
MM
dd
yyyy
The code in question is below: public static string ChangePersianDate(DateTime dateTime) { System.Globalization.GregorianCalendar PC = new System.Globalization.GregorianCalendar(); PC.CalendarType = System.Globalization.GregorianCalendarTypes.USEnglish; return PC.GetYear(dateTime).ToString() + "/" + PC.GetMonth(dateTime).ToString() + "/" + PC.GetDayOfMonth(dateTime).ToString() + "" + PC.…
I want to Change the Format of date selected in DateTimePicker in WPF Application
I'm trying to create a string from the DateTime object which yields the format mm:dd:yyyy. Conventionally the DateTime object comes as mm:dd:yyyy hrs:min:sec AM/PM. Is there a way to quickly remove the hrs:…