1.日期處理
var _d = new Date("2018/01/01 12:00:00"); _d = new Date(_d.valueOf() + 60 * 1000);// 當前時間加上1分鍾 var _d_year111 = _d.getFullYear();//年 var _d_month111 = _d.getMonth() + 1; //月 _d_month111 = (_d_month111 < 10 ? "0" + _d_month111 : _d_month111); var _d_day111 = _d.getDate(); //日 _d_day111 = (_d_day111 < 10 ? "0" + _d_day111 : _d_day111); var _d_hours111 = _d.getHours(); var _d_minutes111 = _d.getMinutes(); var _d_seconds111 = _d.getSeconds(); if (_d_hours111 < 10) _d_hours111 = "0" + _d_hours111; if (_d_minutes111 < 10) _d_minutes111 = "0" + _d_minutes111; if (_d_seconds111 < 10) _d_seconds111 = "0" + _d_seconds111; _data = _d_year111 + "-" + _d_month111.toString() + "-" + _d_day111 + " " + _d_hours111 + ":" + _d_minutes111 + ":" + _d_seconds111;
2.加減 小時
var _d = new Date("2018/01/01 12:00:00"); _d = new Date(_d.valueOf() + 60* 60 * 1000);// 當前時間加上1小時 _d = new Date(_d.valueOf() - 60* 60 * 1000);// 當前時間減掉1小時
_d = new Date(_d.valueOf() + 60 * 1000);// 當前時間加上1分鍾 _d = new Date(_d.valueOf() - 60 * 1000);// 當前時間減掉1分鍾
