Php 字符串编号比较
我有一个包含时间和日期的变量:Php 字符串编号比较,php,Php,我有一个包含时间和日期的变量: $a = "2018-10-19 19:04:53"; 现在我需要检查年份是否大于或等于2019年,如果月份大于01(1月),则检查日期。我试着使用strpos,但没有成功 if (strpos($a, 2018>) !== false) { echo 'true'; 您可以使用以下PHP代码: $a = "2018-10-19 19:04:53"; if (date("Y",strtotime($a)) >= 2018 &
$a = "2018-10-19 19:04:53";
现在我需要检查年份是否大于或等于2019年,如果月份大于01(1月),则检查日期。我试着使用strpos,但没有成功
if (strpos($a, 2018>) !== false) {
echo 'true';
您可以使用以下PHP代码:
$a = "2018-10-19 19:04:53";
if (date("Y",strtotime($a)) >= 2018 && date("m",strtotime($a)) > 01) {
echo 'True';
}
$a=“2019-10-19 19:04:53”;如果(date(“Y”,strotime($a))>=2019&&date(“m”,strotime($a))>01{echo'True';}thanx它可以工作,但我选择了第一个正确的答案。我投了你的赞成票,但不幸的是,我需要至少15次来支持你,这是可行的,但我选择了第一个正确的答案。我支持你,但不幸的是,我至少需要15次投票才能支持你
$a=strtotime('2018-10-19 19:04:53');
$b=strtotime('2019-01-31');
if ($b > $a) {
echo "True";
}
$a = "2018-10-19 19:04:53";
if (date("Y",strtotime($a)) >= 2018 && date("m",strtotime($a)) > 01) {
echo 'True';
}