![将json结果转换为日期[重复],第1张 将json结果转换为日期[重复],第1张](/aiimages/%E5%B0%86json%E7%BB%93%E6%9E%9C%E8%BD%AC%E6%8D%A2%E4%B8%BA%E6%97%A5%E6%9C%9F%5B%E9%87%8D%E5%A4%8D%5D.png)
constructor:
var x = [{ "id": 1, "start": "/Date(1238540400000)/"}, { "id": 2, "start": "/Date(1238626800000)/"}];var myDate = new Date(x[0].start.match(/d+/)[0] * 1);这些部分是:
x[0].start - get the string from the JSONx[0].start.match(/d+/)[0] - extract the numeric partx[0].start.match(/d+/)[0] * 1 - convert it to a numeric typenew Date(x[0].start.match(/d+/)[0] * 1)) - Create a date object
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)