Friday, January 28, 2011

Count day, month and year from two date

$tgl1 = "2009-10-01";  // 1 October 2009
$tgl2 = "2009-11-10";  // 10 October 2009

// break dates to get the date, month and year
// from the first date

$pecah1 = explode("-", $tgl1);
$date1 = $pecah1[2];
$month1 = $pecah1[1];
$year1 = $pecah1[0];

// break dates to get the date, month and year
// from the second date

$pecah2 = explode("-", $tgl2);
$date2 = $pecah2[2];
$month2 = $pecah2[1];
$year2 =  $pecah2[0];

// count JDN from each of the dates

$jd1 = GregorianToJD($month1, $date1, $year1);
$jd2 = GregorianToJD($month2, $date2, $year2);

// compute difference the second day date

$selisih = $jd2 - $jd1;
$month=floor(($selisih - ($tahun * 365))/30);
$day=$selisih - $bulan * 30;

echo "difference the both of the day date is ".$month." month ".$day." day";
This Source is originaly from www.ms-room.com

0 comments:

Post a Comment