Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何创建间隔30天的通知系统_Php - Fatal编程技术网

Php 如何创建间隔30天的通知系统

Php 如何创建间隔30天的通知系统,php,Php,我想创建保修到期日通知。通知应在15天到期前出现在面板上,并在15天到期后在面板上持续,然后进入存档 我的php代码 <?php $exp_date = strtotime('2017-05-01'); $notify_start_date = strtotime('-15 days',$exp_date ); $notify_end_date = strtotime('+15 days', $exp_date); $now = new DateTime(); $now = $now-&g

我想创建保修到期日通知。通知应在15天到期前出现在面板上,并在15天到期后在面板上持续,然后进入存档

我的php代码

<?php
$exp_date = strtotime('2017-05-01');
$notify_start_date = strtotime('-15 days',$exp_date );
$notify_end_date = strtotime('+15 days', $exp_date);
$now = new DateTime();
$now = $now->format('Y-m-d');
$now = strtotime($now);


echo 'expiry date--->'.date('Y-m-d',$exp_date).'<br>';
echo 'nofity start date--->'.date('Y-m-d',$notify_start_date).'<br>';
echo 'nofity end date--->'.date('Y-m-d',$notify_end_date).'<br>';
echo 'today--->'.date('Y-m-d',$now).'<br>';


if ( $exp_date > $notify_start_date  &&  $exp_date < $notify_end_date ) {
    if ($exp_date < $now) {
        echo "already expired";
    } 
    if ($exp_date == $now) {
        echo "will expire today";
    }
    if ($exp_date > $now) {
        echo "going to expire ";
    }
} else {
    echo 'false';
}
?>

我的代码显示了15天以后的通知,无论是在之前还是之后
如果我给出的日期2017-06-31仍然显示在通知面板中,并显示过去的所有过期日期,那么您的代码似乎是正确的,但您需要实现什么样的目标?在if/else条件下,我只是根据结果修改了echo->这是您想要的吗?谢谢您的快速回复。我得到了它。我的MySql查询是错误的。我只是做了这个
SELECT*FROM
而不是
SELECT*FROM其中WEXP\u DATE=DATE\u ADD(CURDATE(),INTERVAL-15天)那么一切都好:)