switch
2013-09-26 20:18:47 +08:00
比较简单的:
var date1 = "2013-01-01 09:00";
var date2 = "2013-01-03 12:00";
var d1 = new Date(date1.replace(/[- ]/g, ","));
var d2 = new Date(date2.replace(/[- ]/g, ","));
var d = d1;
while (d <= d2) {
console.log([d.getFullYear(), ("0" + (d.getMonth() + 1)).slice(-2), ("0" + d.getDate()).slice(-2)].join("-") + " " + [("0" + d.getHours()).slice(-2), ("0" + d.getMinutes()).slice(-2)].join(":"));
d.setHours(d.getHours() + 1);
}