C# .NET - i want to get date dd/MM/yyyy format but am getting dd-MM-yyyy format
Asked By Srikar Reddy on 09-Apr-15 02:58 AM
Hi All,
i want to get date dd/MM/yyyy format but am getting dd-MM-yyyy format , i tried with
var currentDate1 = DateTime.Now.ToString("dd/MM/yyyy");-- this also giving the data dd-MM-yyyy format.
2) and tried with another option
System.Globalization.DateTimeFormatInfo MyDateTimeFormatInfo = new System.Globalization.DateTimeFormatInfo();
MyDateTimeFormatInfo.ShortDatePattern = "M/d/yyyy";
var StartDate = DateTime.Parse(dt.ToString("MM/dd/yyyy",MyDateTimeFormatInfo));
here am getting An exception of type 'System.FormatException' occurred in mscorlib.dll Error
can anyone help me in this.