代码如下: function dateFormat(date, format) { var o = { “M+”: date.getMonth() + 1, //month “d+”: date.getDate(), //day “h+”: date.getHours(), //hour “m+”: date.getMinutes(), //minute “s+”: date.getSeconds(), //second “q+”: Math.floor((date.getMonth() + 3) / 3), //quarter “S”: date.getMilliseconds() //mi