在PHP之前,如何检查操作是否发生在最近5天之前? [英] How do I check to see if action occurred up to 5 days before today in PHP?
本文介绍了在PHP之前,如何检查操作是否发生在最近5天之前?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个功能来查看是否在今天的最近5天内发送短信。我已经可以检查今天是否发送了(见下文),但是我早在5天前就已经遇到了困难。
I'm working on a function to see if an SMS was sent within the last 5 days of 'today'. I can already check if it's been sent today (see below) but I'm struggling with the up to 5 days earlier part.
// Check if SMS already sent today
if ($this->sms_sent == $today->format('Y-m-d'))
{
return true;
}
我需要知道短信是否在5天前发送。 / p>
I need to know if the SMS was sent up to 5 days ago.
推荐答案
使用此
$now=date('Y-m-d');
$days_ago = date('Y-m-d', strtotime('-5 days', strtotime($now )));//get five days before date
if($this->sms_sent <= $now && $this->sms_sent >= $days_ago) {
// It's between
}
这篇关于在PHP之前,如何检查操作是否发生在最近5天之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文