将日期时间从javascript传递到WCF的最佳方法
我有个问题,从WCF到JS来回传递DateTime的最佳方式是什么?我目前正在使用普通的WCF,其中我为模型定义了DataContract,其中我有很多类型的属性,如DateTime、string、int等。当我调用此服务时,我使用JSON对象,日期如下“/Date(firstNum+secondNum)” 对于parse date,我使用这个函数将日期时间从javascript传递到WCF的最佳方法,javascript,c#,rest,wcf,datetime,Javascript,C#,Rest,Wcf,Datetime,我有个问题,从WCF到JS来回传递DateTime的最佳方式是什么?我目前正在使用普通的WCF,其中我为模型定义了DataContract,其中我有很多类型的属性,如DateTime、string、int等。当我调用此服务时,我使用JSON对象,日期如下“/Date(firstNum+secondNum)” 对于parse date,我使用这个函数 var date = new Date(parseInt(jsonDate.substr(6))); 没关系。日期与我从WCF传递的DateTim
var date = new Date(parseInt(jsonDate.substr(6)));
没关系。日期与我从WCF传递的DateTime对象相同
问题是何时我想将此日期传递给WCF。我正在使用ajax
$.ajax({
type: POST,
url: "myserviceUrl",
data: JSON.stringfy({myDate: $("#mypicker").val()}), //for example 24.3.2000 0:00:00
contentType: "application/json; charset=utf-8",
dataType: json,
success: function(msg) {
alert(msg);
},
error: funstion(e) {}
});
我通过了“24.3.2000 0:00:00”,但在WCF中,我使用时间戳为“23.3.2000 23:00:00”的datetime,我不知道为什么:/。。。有什么想法吗?这个解决方案可以帮助我。谢谢你的回答。我用现在,js,这个解决方案帮助我。谢谢你的回答我利用这个时刻,js,: