satisfy(time) => {
var nowDate = new Date();
var mouth = nowDate.getMonth() + 1;
var day = nowDate.getDate();
var year = nowDate.getFullYear() - 18;
if (mouth === 2 && day >= 28) {
day = this.isOrdinaryYear(year) ? 28 : 29;
}
var oldDate;
if (isIOS()) {
oldDate = new Date(year + '/' + mouth + '/' + day).getTime();
} else {
oldDate = new Date(year + '-' + mouth + '-' + day).getTime();
}
return oldDate < time ? true : false;
};
function isIOS() {
var u = navigator.userAgent;
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
return isiOS;
}
- 值得注意的是ios上转换时间戳的兼容性问题,上述oldDate如果不进行处理,你会发现IOS端会一直返回true不能达到判断是否大于十八岁