如何使用JSON.NET通过ASP.NET MVC传递一个JSON日期值? [英] How to pass a JSON date value via ASP.NET MVC using JSON.NET?

查看:131
本文介绍了如何使用JSON.NET通过ASP.NET MVC传递一个JSON日期值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  格式化微软JSON的日期?

在ASP.NET功能 JSON()格式,并返回一个日期

The ASP.NET function Json() formats and returns a date as

{"d":"\/Date(1240718400000)\/"}

其具有与在客户端这是有问题的处理。你有什么办法为建议发送日期值来回?

which has to be dealt with on the client side which is problematic. What are your suggestions for approaches to sending date values back and forth?

推荐答案

这是在另一帖子对堆栈 溢出:

This was found in another post on Stack Overflow:

var date = new Date(parseInt(jsonDate.substr(6))); 

SUBSTR函数取出/日期(部分,而parseInt函数函数获取整数并忽略)/结尾。得到的号码被传递到Date构造函数。

The substr function takes out the "/Date(" part, and the parseInt function gets the integer and ignores the ")/" at the end. The resulting number is passed into the Date constructor.

这篇关于如何使用JSON.NET通过ASP.NET MVC传递一个JSON日期值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆