JS时间日期格式转换

  第一种:
function ConvertJSONDate(jsondate) {
        if (jsondate != "" && jsondate != null) {
            var date = new Date(parseInt(jsondate.replace("/Date(", "").replace(")/", ""), 10));
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var day = date.getDate();
            return year + '-' + (month < 10 ? ('0' + month) : month) + '-' + (day < 10 ? ('0' + day) : day);
        }
        else {
            return jsondate;
        }
    }
 
 
第二种简单算法:
 function formatDate(src) {             if (src != null) {                 var date = eval("new " + eval(src).source);                 return date.format("yyyy-MM-dd");             } else {                 return "";             }         }
相关文章
相关标签/搜索