js反序列化时间

时间:2014-06-28 17:46:58   收藏:0   阅读:262

 var time = "/Date(1279270720000+0800)/";

var tme1 = ChangeDateFormat(time); alert(tme1);

bubuko.com,布布扣
JS方法为:
 
function ChangeDateFormat(cellval) {
    var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
    var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
    var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
    return date.getFullYear() + "-" + month + "-" + currentDate;
}

js反序列化时间,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!