Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.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 在特定日期前60天显示消息_Php - Fatal编程技术网

Php 在特定日期前60天显示消息

Php 在特定日期前60天显示消息,php,Php,我想在特定日期前60天显示一条消息 我制作了以下脚本: $current = date("Ymd"); // this is the current date 20162306 $time = strtotime($row3["data_scadenza_arbo"]); $notify = date('Ymd', $time); // this is the date inside the db (is 20162322) 我将日期转换为数字,但我不知道如何前进。这可以帮助您,如果通知尚

我想在特定日期前60天显示一条消息

我制作了以下脚本:

$current = date("Ymd"); // this is the current date 20162306

$time = strtotime($row3["data_scadenza_arbo"]);

$notify = date('Ymd', $time); // this is the date inside the db (is 20162322)

我将日期转换为数字,但我不知道如何前进。

这可以帮助您,如果通知尚未发送,您可能需要一些标志

if(strtotime($date_from_db) > time()-(60*60*24*60)) sendNotification();
使用日期时间 您最好使用DateTime类来操纵和比较日期:

我为你想出了一个小片段:

<?php

$current = new DateTime();

$notify = new DateTime($row3["data_scadenza_arbo"]);

$difference = $current->diff($notify);

var_dump($difference->days); // remaining days (integer)

您想显示什么样的消息?你在用什么图书馆?您是否希望现在显示一条消息,告知用户该日期?如果今天是那个特殊的日子,你想发个短信吗?如果今天是在那个特别的日子之后,你想发一条消息吗?