网站首页 javascript技术
javascript --获取当前日期是不是当天
发布时间:2019-01-23 02:14查看次数:2287
console.log(checkNumber());
function checkNumber(){
var _times = Number(localStorage.getItem("Lottery.times"));
var _timesNumber = Number(localStorage.getItem("Lottery.number"));
var _newDay = getDayTime();
if(_times == null){
_times = getDayTime();
localStorage.setItem("Lottery.times",_times.toString());
}
if(_timesNumber == null){
_timesNumber = 1
localStorage.setItem("Lottery.number",1);
}
if(_newDay == _times){
if (_timesNumber < 10 ) {
_timesNumber = _timesNumber + 1
localStorage.setItem("Lottery.number",_timesNumber.toString());
return true;
}else{
return false;
}
console.log("是一天")
}else{
localStorage.setItem("Lottery.times",_newDay.toString());
_timesNumber = 1
localStorage.setItem("Lottery.number",_timesNumber.toString());
}
return true;
}
function getDayTime(){
var _temp_tiem = new Date();
var _y = _temp_tiem.getFullYear();
var _m = _temp_tiem.getMonth() + 1;
var _d = _temp_tiem.getDate();
var _str = _y +":"+_m+":"+_d;
var _time = new Date(_str).getTime();
return _time;
}
关键字词:javascript##