Jump to content

Simple date calc


johnsmith153

Recommended Posts

Perhaps...

 

<?PHP
function MonthDiff($start_date, $end_date) {
$array01 = explode("/", $start_date);
$array02 = explode("/", $end_date);
$start_date2 = $array01[1] . "/" . $array01[0] . "/" . $array01[2]; 
$end_date2 = $array02[1] . "/" . $array02[0] . "/" . $array02[2]; 
$ts1=strtotime($start_date2);
$ts2=strtotime($end_date2);
$m_diff = floor(($ts2-$ts1)/2628000);
return $m_diff;
}
$start_date = "06/11/2010";
$end_date = "10/02/2011";
echo MonthDiff($start_date, $end_date);
$end_date = "01/02/2011";
echo "<br>";
echo MonthDiff($start_date, $end_date);
?>

Link to comment
https://forums.phpfreaks.com/topic/217969-simple-date-calc/#findComment-1131202
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.