正确的方法,从数据库格式日期使用JavaScript / jQuery的 [英] Proper way to format date from database using javascript/jquery
问题描述
我打电话给我的数据库,其中包含datetime数据类型。日期看起来是这样的:
I am calling my database which contains a datetime datatype. The date looks like this:
16 2005-05-23:06:00.000
2005-05-23 16:06:00.000
我想在一个表格中显示此当用户从列表中选择某一个项目。我把我的控制器操作和返回的所有时间JSON和把它们放在一个表。问题是,日期是完全错误的。什么是显示的是这样的:
I would like to display this in a table when a user selects a certain item from a list. I call my controller action and return Json of all the times and put them in a table. The problem is the date is completely wrong. What is displayed is this:
/日期(1255470180000)/
/Date(1255470180000)/
返回的日期甚至不是可解析(我不想做的工作),所以我甚至无法获得数据,如果我想。任何想法?
The date that is returned isn't even parsable (which I don't want to do anyway) so I can't even get the data if I wanted to. Any ideas?
推荐答案
我结束了在控制器动作格式化code来代替。
I ended up formatting the code in the controller action instead.
我只投的日期时间属性使用的ToString()的字符串,并得到想要的结果。
I just cast the datetime property to a string using .ToString() and got the desired results.
感谢您的帮助虽然球员。
Thanks for the help though guys.
这篇关于正确的方法,从数据库格式日期使用JavaScript / jQuery的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!