使用JSON(Jquery)返回自定义日期格式 [英] Custom Date format return using JSON (Jquery)
本文介绍了使用JSON(Jquery)返回自定义日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有人,
我试图从asp.net网页方法返回一个日期并返回给我
/日期(1224043200000)/我尝试使用DateFormat库使用下面的解决方案,但它总是返回当前日期。
我想我传递了正确的参数,如解决方案,但它只返回当前日期。
http://stackoverflow.com/questions/206384/how-to-format-a-json-date
希望有人可以帮助我
问候
Omer
Dear All,
I am trying to return a date from a asp.net webpage method and it returns me
/Date(1224043200000)/ I tried using the solution below using the DateFormat Library but It always returns a current date.
I think I am passing the correct parameters as mentioned in the solution, but still it only returns the current date.
http://stackoverflow.com/questions/206384/how-to-format-a-json-date
Hope some one can help me
Regards
Omer
推荐答案
我能够使用下面的解决方案解决它
result.d.dob是我的输入值/日期(1224043200000)/并返回MM / dd / yyyy格式。
I was able to resolve it using the following solution below
result.d.dob is my input value /Date(1224043200000)/ and it returns a MM/dd/yyyy format.
var value = result.d.dob;
if (value.substring(0, 6) == "/Date(") {
var dt = new Date(parseInt(value.substring(6, value.length - 2)));
var dtString = (dt.getMonth() + 1) + "/" + dt.getDate() + "/" + dt.getFullYear();
}
(' #dob')。val(dtString);
('#dob').val(dtString);
这篇关于使用JSON(Jquery)返回自定义日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文