I am only trying to return the date in my MVC application and have come across a problem. I have applied to my model DataFormatString = "{0:dd/M/yy}"
and have also included ApplyFormatInEditMode = true
as suggested from these posts ASP.NET MVC displaying date without time and Displaying Date only MVC
I am however generating the field to include the next 5 week commencing dates as shown here into a dropdownlist http://prntscr.com/ak825u.
This is done through the following code
// GET: TimeSheets/Create
public ActionResult Create()
{
int weekCount = 5;
List<DateTime> listDates = new List<DateTime>();
for (int i = 0; i < (weekCount * 7); ++i) //Get next 5 weeks
{
//Adds only next 5 mondays to the list of dates
if (DateTime.Today.AddDays(i).DayOfWeek == DayOfWeek.Monday)
listDates.Add(DateTime.Today.AddDays(i));
}
ViewData["DateList"] = new SelectList(listDates);
return View();
}
How would I go about removing the time to just display the date