// 获取当前时间 function getNowFormatDate(obj) { var date = new Date(obj*1000); var seperator1 = "-"; //年月日的显示格式 var seperator2 = ":"; //时分秒的显示格式 var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } function get(i){return (i < 10 ? '0' : '') + i} var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + get(date.getHours()) + seperator2 + get(date.getMinutes()) + seperator2 +get(date.getSeconds()); /ar currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + get(date.getHours()) + seperator2 + get(date.getMinutes()) + seperator2 +get(date.getSeconds()); return currentdate;
}
显示效果为
2016-11-18 9:55:30