从webservice解析日期 [英] Parsing Date from webservice
本文介绍了从webservice解析日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从网络服务获取日期,他们看起来像这样:
I'm getting dates back from a webservice, and they look like this:
/日期(1310187160270 + 1200)/
如何在javascript中将其转换为日期对象?
How would I go about converting this to a date object in javascript?
I我已经搜索了一下,找不到一个体面的答案 - 这可能部分是因为我不太清楚这种类型的日期对象是被调用的 - 所以如果有人能够清楚地说明这一点,那么
I've googled around a bit and cannot find a decent answer - this may be in part due to the fact that I'm not exactly sure what this type of date object is called - so if someone could shed light on that also, that would be appreciated.
推荐答案
var date = new Date(1310187160270+1200);
console.log(date)
返回
Sat Jul 09 2011 06:52:41 GMT + 0200(南非标准时间)
Sat Jul 09 2011 06:52:41 GMT+0200 (South Africa Standard Time)
如果您需要按照问题进行剥离: / p>
If you need to strip it as is in Question:
var returnVariable = "/Date(1346713200000+0100)/";
var d = new Date(parseFloat(returnVariable.replace("/Date(", "").replace(")/", "")));
这篇关于从webservice解析日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文