Json 的日期格式到.net datetime格式

Json 的日期格式如:"/Date(1243453335497+0800)/" ,为了正确输出如下格式“ 2011年5月15日 15:39:00”,需要进行转换,

提供脚本函数如下:

 function dateFromStringWithTime(str) {
        var match;
        if (!(match = str.match(/\d+/))) {
            return false;
        }
        var date = new Date();
        date.setTime(match[0] - 0);
        return date.toLocaleString();
    }

 var objDate = dateFromStringWithTime(result.Items[msg].PostTime);

objDate即为所要的时间格式。

如: 2011年5月15日 12:12:00

阅读全文
类别:程序人生 查看评论
原文地址:https://www.cnblogs.com/fbb/p/2659322.html