2 回答

TA贡献1757条经验 获得超8个赞
您应该尝试location.replace():
<script>
function checkDate() {
var date = new Date();
console.log(date.getDay());
console.log(date.getHours());
console.log(date.getMinutes());
console.log(date.getSeconds());
if(date.getDay() === 3 && date.getHours() ===13 && date.getMinutes() === 33 && date.getSeconds() === 1) {
location.replace("<?php echo base_url(); ?>test/send_mail_account");
}
}
var dateLoop = setInterval(function() {
checkDate();
},5000);
</script>

TA贡献1812条经验 获得超5个赞
您的“如果”条件出错,并且始终无法满足所有条件。您可以删除'date.getSeconds() === 1'或更改'5000'为'1000'(每秒运行)。
<script>
function checkDate() {
var date = new Date();
console.log(date.getDay());
console.log(date.getHours());
console.log(date.getMinutes());
console.log(date.getSeconds());
if(date.getDay() === 3 && date.getHours() ===13 && date.getMinutes() === 33 ) {
window.location.replace("<?php echo base_url(); ?>test/send_mail_account");
}
}
var dateLoop = setInterval(function() {
checkDate();
},5000);
</script>
设置为 Cron 作业
使用以下命令编辑 cron 选项卡
crontab -e
添加以下行以在星期三 13:33 运行它(对路径进行必要的更改)
33 13 * * 3 /php.ini-folder-path/php /path/to/codeigniter/root/index.php test send_mail_account
添加回答
举报