【发布时间】:2013-09-02 09:05:54
【问题描述】:
场景: 我知道这是一个简单的日期时间转换,但我是后端和转换的新手。所以请帮助:我使用 mvc 和 ajax 将日期从 kendocalender 传递到调度程序以将其保存在数据库中: 这是我的代码: 控制器.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;
}
index.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");
});
});
问题:
这是呼叫警报
如何将此输出从 kendocalendar 转换为 "2013-09-01 13:27:14.480"(yyyy-mm-dd hh-mm-ss.sss) 这种格式使用 jquery 通过控制器功能将其保存在数据库中.请帮忙。
【问题讨论】:
标签: c# asp.net-mvc-3 jquery