How do I display a date format in dd/MM/yyyy to ddd, dd/MM/yyyy (Mon, 1/4/2014) format with this logic?

StackOverflow https://stackoverflow.com/questions/22779254

سؤال

Right now I have been given the code below code to get the selected date from a calendar and displays it into a textbox but it's in dd/MM/yyyy format.

txtSMAlerted_PopupControlExtender.Commit(calSMAlerted.SelectedDate.ToShortDateString());
هل كانت مفيدة؟

المحلول

It is simply a format string passed to the ToString method of the DateTime

 calSMAlerted.SelectedDate.ToString("ddd, dd/MM/yyyy");

The ToString(string) overload of DateTime accepts a Standard Date Format String as well as a Custom Date And Time Format String.
With this last set of rules it is easy to build your required output format.

نصائح أخرى

Try this:

calSMAlerted.SelectedDate.ToString("ddd, dd/MM/yyyy")

you should parse datetime into string like this:

calSMAlerted.SelectedDate.ToString("ddd, d/M/yyyy");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top