Ashish Ashish - 3 months ago 14
ASP.NET (C#) Question

Calendar Extender date picking and converting into correct format

i am picking the value from calender extender in textbox and i am getting the value in the format

but i want it in the format
in another textbox
) as code shown below

DateTime wrongformat = DateTime.Parse(TextBox4.Text);
String rightformat = String.Format("{0:dd/MM/yyyy}", wrongformat.Date);
txt_actualrightformat.Text = rightformat.ToString();


DateTime is irespective of the format, format is only for displaying purpose. If you are not getting the right date in wrongformat then you can use DateTime.ParseExact with the format. and then simply

txt_actualrightformat.Text = wrongformat.ToString("dd/MM/yyyy");


use DateTime.ParseExcat like:

DateTime dt = DateTime.ParseExact(TextBox4.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture);
txt_actualrightformat = dt.ToString("dd/MM/yyyy");