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

<?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)));

转:http://www.oschina.net/code/snippet_1182885_56205

上一篇:HTML5学习笔记(二十九):Cookie和Session


下一篇:vue2.x学习笔记(二十九)