json时间转换的两种方式

//yyyy-MM-dd
function JsonToDate(jsondate) {
    var date = new Date(parseInt(jsondate.replace("/Date(", "").replace(")/", ""), 10));
    return getDate(date);
}      
 function getDate(date) {
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var day = date.getDate();

            return year + "-" + month + "-" + day;
        }

//yyyy-MM-dd hh:mm:ss
function JsonToDateTime(jsondate) {
    var date = new Date(parseInt(jsondate.replace("/Date(", "").replace(")/", ""), 10));
    return getDateTime(date);

        function getDateTime(date) {
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var day = date.getDate();
            var hh = date.getHours();
            var mm = date.getMinutes();
            var ss = date.getSeconds();
            return year + "-" + month + "-" + day + " " + hh + ":" + mm + ":" + ss;

        }

posted @ 2013-05-02 16:10  ~KG~  阅读(358)  评论(0编辑  收藏  举报