js获取三天后的日期
- setDate
getNowAddTreeFormatDate() {
var date = new Date();
date.setDate(date.getDate()+3);//获取3天后的日期
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
var monthStr:string;
var day = date.getDate();
var dayStr:string;
if (month >= 1 && month <= 9) {
monthStr = "0" + month.toString();
}else{
monthStr = month.toString();
}
if (day >= 0 && day <= 9) {
dayStr = "0" + day.toString();
}else{
dayStr = day.toString();
}
var currentdate = date.toISOString(); //date.getFullYear() + seperator1 + month + seperator1 + dayStr + 'T00:00:00+08:00'
;
return currentdate;
}
- 加上3天的时间戳
// 交付时间为当前时间3天后
let year=new Date(new Date().getTime()+259200000).getFullYear();
let month=new Date(new Date().getTime()+259200000).getMonth()+1;
let newMonth:any;
if(month<10){
newMonth='0'+month;
}else{
newMonth=month;
}
let day=new Date(new Date().getTime()+259200000).getDate();
this.task.handInTime=year+'-'+newMonth+'-'+day;
- 手机振动
var p = document.getElementById("message");
var supportsVibrate = "vibrate" in navigator;
supportsVibrate ? y() : n();
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
function y() {
p.innerHTML = "你的手机已被我控制了,我就问你怕不怕,慌不慌 !!!";
navigator.vibrate([1000, 1000, 1000, 1000, 1000]);
} function n() {
isIOS ? p.innerHTML = "土豪用的苹果手机,惹不起惹不起" : "不支持震动";
}