Php 在特定日期前60天显示消息
我想在特定日期前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) 我将日期转换为数字,但我不知道如何前进。这可以帮助您,如果通知尚
$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)
您想显示什么样的消息?你在用什么图书馆?您是否希望现在显示一条消息,告知用户该日期?如果今天是那个特殊的日子,你想发个短信吗?如果今天是在那个特别的日子之后,你想发一条消息吗?