js,json序列化及日期时间处理



日期处理函数 

  function ChangeDateFormat(jsondate) {    
   jsondate = jsondate.replace("/Date(", "").replace(")/", "");    
   if (jsondate.indexOf("+") > 0) {   
        jsondate = jsondate.substring(0, jsondate.indexOf("+"));    
    }    
     else if (jsondate.indexOf("-") > 0) {   
         jsondate = jsondate.substring(0, jsondate.indexOf("-"));    
     }    
    
    var date = new Date(parseInt(jsondate, 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;   
 } 

json序列化

toJson方法

jquery.json-2.2.min.js

你可能感兴趣的:(移动互联网)