0
点赞
收藏
分享

微信扫一扫

php实现比较两个字符串日期大小的方法

鱼满舱 2022-09-27 阅读 112

<?php
function dateBDate($date1, $date2) {
// 日期1是否大于日期2
$month1 = date("m", strtotime($date1));
$month2 = date("m", strtotime($date2));
$day1 = date("d", strtotime($date1));
$day2 = date("d", strtotime($date2));
$year1 = date("Y", strtotime($date1));
$year2 = date("Y", strtotime($date2));
$from = mktime(0, 0, 0, $month1, $day1, $year1);
$to = mktime(0, 0, 0, $month2, $day2, $year2);
if ($from > $to) {
return true;
} else {
return false;
}
}
?>
$date1 = "2009-10-13";
$date= mktime(0, 0, 0, date("m", strtotime($date1)), date("d", strtotime($date1)), date("Y",strtotime($date1)));

举报

相关推荐

0 条评论