var now = new Date();
var dayMill = 1000 * 60 * 60 * 24;
var beginMill = Math.floor(now.getTime() / day) * day;
var begin = new Date(beginMill);
上面的begin是UTC标准的当天0时, 在北京时间显示的是早上八点, 如果需要获取北京时间0时, 需要加上时区差:
var beginMill = Math.floor(now.getTime() / day) * day
+ now.getTimezoneOffset() * 60 * 1000;
var begin = new Date(beginMill);
在前面今天0时的基础上加上一天的毫秒数即可
var tomorrowMill = beginMill + dayMill;
var tomorrowBegin = new Date(tomorrowMill);