场景:我知道这是一个简单的日期时间转换,但我是后端和转换的新手。所以请帮助:我使用 mvc 和 ajax 将日期从 kendocalender 传递到调度程序以将其保存在数据库中:这是我的代码:controller.cs
public int insertnote(string model,DateTime kendodate)
{
tblDailyNotes Dnote = new tblDailyNotes();
int noteid = 0;
//note.RealDate=Convert.ToString(
Dnote.Note = model;
Dnote.RealDate = kendodate;
noteid = _scheduler.InsertDailynote(Dnote);
return noteid;
}
索引.cshtml
$("#dailynotes").change(function () {
debugger;
alert("Changed");
var dailynotes = $('#dailynotes').val();
var calendar = $("#SchedulerCalendar2").data("kendoCalendar");
var cal = calendar.value(new Date());
alert(cal);
$.ajax({
![enter image description here][1]
type: "POST",
url: window.location.pathname + "Scheduler/insertnote",
data: {model:dailynotes, kendodate: cal }
})
.success(function (result) {
alert("note saved successfully");
});
});
问题:
这是 cal 警报
如何将此输出从 kendocalendar 转换为“2013-09-01 13:27:14.480”(yyyy-mm-dd hh-mm-ss.sss)这种格式,使用 jquery 通过控制器功能将其保存在数据库中。请帮忙。