php question... how to check if something is between two values?(php问题...如何检查两个值之间是否有东西?)
问题描述
我知道我在这里遗漏了一些简单的东西...我一直在尝试不同的运算符,但无法解决这个问题...
I know I'm missing something easy here... I've been trying different operators, but haven't been able to figure this out...
如何检查当前日期是否在另外两个日期之间?
How do I go about checking to see if the current date is between two other dates?
那么,如果我的起始日期为 2010 年 2 月 2 日,截止日期为 2010 年 2 月 10 日,如果当前日期(2010 年 2 月 4 日)介于这两个日期之间,我如何返回 TRUE?
So, if I have a from date of 2/2/2010 and a to date of 2/10/2010, how can I return TRUE if the current date (2/4/2010) falls between those two dates?
推荐答案
要进行这样的比较,您需要进行单独的比较.如果 $d 是您要比较的日期,$d1 是较早的日期,$d2 是较晚的日期,则类似于:
To do a comparison like this you need to do separate comparisons. If $d is the date you want to compare, $d1 is the earlier date, and $d2 is the later date, it would be something like:
if ((strtotime($d) > strtotime($d1)) and (strtotime($d) < strtotime($d2))) {
return true;
} else {
return false;
}
这篇关于php问题...如何检查两个值之间是否有东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:php问题...如何检查两个值之间是否有东西?


- 没有作曲家的 PSR4 自动加载 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Laravel 仓库 2022-01-01