EasyuUI时间的一个转换

//-----<th data-options="field:'time',width:220,align:'center',title:'创建时间'" formatter = formatOperTime ></th>

//service层 -------  Date currentTime = new Date();
  
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  
  String dateString = formatter.format(currentTime);
//----------js
function formatOperTime(action_time){

     var date = new Date(action_time);
     var year = date.getFullYear().toString();
     var month = (date.getMonth() + 1);
     var day = date.getDate().toString();
     var hour = date.getHours().toString();
     var minutes = date.getMinutes().toString();
     var seconds = date.getSeconds().toString();
     if (month<10) {
month="0"+month;
}
    
     if (day<10) {
day="0"+day;
}
    
     if (hour<10) {
hour="0"+hour;
}
    
     if (minutes<10) {
minutes="0"+minutes;
}
    
     if (seconds<10) {
seconds="0"+seconds;
}
    
     return year + "-" + month + "-" + day + " " + hour + ":" + minutes + ":" + seconds;

}

猜你喜欢

转载自2017.iteye.com/blog/2368812