如何将Json日期时间转换为正常日期时间格式? [英] How Can I Convert Json Datetime To Normal Date Time Format?

查看:1083
本文介绍了如何将Json日期时间转换为正常日期时间格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Json DateTime字符串转换为普通日期格式?



我将Json DateTime视为

How can I convert a Json DateTime string to normal dateformat?

I get the Json DateTime as








Datestamp": "2014-10-05T00:00:00".





这里Datestamp是列名。



我需要用Javascript编写一个函数。这个有趣的有两个参数,一个是'Datestamp',另一个是'Dateformate'。我需要将此'Datastamp'转换为给定日期'Dateformate',函数将返回此DateTime。



请通过提供此代码来帮助我。



提醒我的Datestamp参数将始终获得此类型的字符串foramte2014-10-05T00:00:00 。



Here Datestamp is the column name.

I need to write a function using Javascript. This functing has two parameter one is this 'Datestamp', another is 'Dateformate'. I need to convert this 'Datastamp' as given date 'Dateformate' and function will return this DateTime.

Please help me by providing this code.

Remind that my Datestamp parameter will always get this type of string foramte "2014-10-05T00:00:00".

推荐答案

检查此链接是否有帮助。



http://mvcworld.blogspot.in/2013/06/convert-json-date-to-javascript-日期。 html [ ^ ]
Check this link hope it helps.

http://mvcworld.blogspot.in/2013/06/convert-json-date-to-javascript-date.html[^]


使用新的Date()创建日期对象。



例如。
Date objects are created with new Date().

For example.
var date = new Date(Datestamp);


var date = new Date(parseInt(Datestamp.substr(10)));

这里substr函数取出/ Date(部分,而parseInt函数获取整数并忽略最后的)/。生成的数字将传递给Date构造函数。
var date = new Date(parseInt(Datestamp.substr(10)));
here 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日期时间转换为正常日期时间格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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