2013年10月7日星期一

Ask a json time format conversion problems

I'm in the class inside the time is " 2013-09-22 00:00:00.0 " like this,
becomes converted into json Such a .. how to get him back to normal display ?
------ Solution ------------------------------------------- -

把createtime做为参数传进去就好了
function dateFormat(time){
         if(!time){
         return "";
         }
         var tmp = eval(time);
         var date = new Date();
date.setTime(tmp.time);
var year = date.getYear();
var month = date.getMonth() + 1;
var day = date.getDate(); //获取当前日(1-31)
     /*var hour = date.getHours(); //获取当前小时数(0-23)
     var minute = date.getMinutes(); //获取当前分钟数(0-59)
     var second = date.getSeconds(); //获取当前秒数(0-59)*/
     month=month<10?("0"+month):month;
     day=day<10?("0"+day):day;
     /*hour=hour<10?("0"+hour):hour;
     minute=minute<10?("0"+minute):minute;
     second=second<10?("0"+second):second;*/
     var dateStr = year + "-" + month + "-" + day;
     //dateStr = dateStr + " " + hour + ":" + minute + ":" + second;
     return dateStr;
        }

没有评论:

发表评论