比较php中的日期字符串与mm-dd-yy格式
我需要比较字符串中的两个日期, 我的约会: 第一天:11-11-19 第二天:11-24-17 所以我试着比较php中的日期字符串与mm-dd-yy格式,php,date,datetime,compare,Php,Date,Datetime,Compare,我需要比较字符串中的两个日期, 我的约会: 第一天:11-11-19 第二天:11-24-17 所以我试着 $firstdate = "11-11-19"; $seconddate = "11-24-17"; if($firstdate < $seconddate) { echo "firstdate is minor than the secondate"; } else { echo "seconddate is maj
$firstdate = "11-11-19";
$seconddate = "11-24-17";
if($firstdate < $seconddate)
{
echo "firstdate is minor than the secondate";
}
else
{
echo "seconddate is major than the firstdate";
}
$firstdate=“11-11-19”;
$seconddate=“11-24-17”;
如果($firstdate<$seconddate)
{
echo“firstdate比secondate小”;
}
其他的
{
echo“第二个日期比第一个日期重要”;
}
如果我改变<或>if语句应该改变,但我总是得到第一个日期。。。
如何比较本表格中的两个日期mm dd yy?
谢谢您可以使用它将字符串转换为unix时间戳,并进行比较
$firstdate=strottime(“11-11-19”);
$seconddate=strottime(“11-24-17”);
如果($firstdate<$seconddate)
{
echo“firstdate比secondate小”;
}
其他的
{
echo“第二个日期比第一个日期重要”;
}
您可以将两个日期转换为时间戳:
echo (strtotime($firstdate) < strtotime($seconddate)) ? "firstdate is minor than the secondate" : "seconddate is major than the firstdate";
echo(strotime($firstdate)
我确信这不是故意的,但这与我之前发布的答案相同。:)