--- hour 加減 ---
Date.prototype.addHours = function( h ){
this.setHours(this.getHours() + h );
return this;
}
addHours(5); //這樣就會加五個小時喔XDD
--- 取得 每個 ---
會用到這個,是因為好多地方用到但又不一樣格式XDDD
let date_item = {
year: d.getFullYear(),
month: ((d.getMonth() + 1) < 10 ? '0' : '') + (d.getMonth() + 1),
day: (d.getDate() < 10 ? '0' : '') + d.getDate(),
hour: (d.getHours() < 10 ? '0' : '') + d.getHours(),
min: (d.getMinutes() < 10 ? '0' : '') + d.getMinutes()
};
--- 增加1天 ---
感覺跟第一個hour加減很像
var date = new Date();
// add a day
date.setDate(date.getDate() + 1);
--- 設定hour為00:00 ---
var d = new Date();
d.setHours(0,0,0,0);
以此類推
var d = new Date();
d.setSeconds(0,0,0,0);
留言列表