I want to pull a date from db and display it in a telerik ddl. I am able to pull the date and display it, but cant get the formatting to work. The date is display like this:
/Date(13496724000000)/
Here is my Controller action to pull the date from db:
[HttpPost]
public ActionResult Date(int id)
{
var dates = (from p in db.vwdb.Where(u => u.Id == id)
group p by p.Date into g
select g.Key).ToList();
return Json(new { data = Convert.ToDateTime(weeks.Min())});
}
Here is my jquery to display it in ddl:
function populateDate() {
var link = '/Users/Date';
var dataSource = [];
$.ajax({
type: 'POST',
url: link,
data: { id: id },
dataType: 'json',
success: function (result) {
var dateOf = result.data;
dataSource.push({ Text: dateOf , Value: dateOf });
$("#Date").data("tDropDownList").dataBind(dataSource);
},
error: function (result) {
alert(result.message);
}
});
};
I want to display the date in this format: "MM/DD/YYYY" instead of "/Date(13496724000000)/"
Any help is much appreciated.