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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM