date("Y", $diff) - $base_year, "months_total" => (date("Y", $diff) - $base_year) * 12 + date("n", $diff) - 1, "months" => date("n", $diff) - 1, "days_total" => floor($diff_secs / (3600 * 24)), "days" => date("j", $diff) - 1, "hours_total" => floor($diff_secs / 3600), "hours" => date("G", $diff), "minutes_total" => floor($diff_secs / 60), "minutes" => (int) date("i", $diff), "seconds_total" => $diff_secs, "seconds" => (int) date("s", $diff) );
}
$tgl1 = '1989-06-06';
$tgl2 = date("Y/m/d/ h:m:s");
$a = datediff($tgl1, $tgl2);
echo 'tanggal 1 = '.$tgl1; echo '
';
echo 'tanggal 2 = '.$tgl2; echo '
';
echo 'Selisih = '.$a[years].' tahun '.$a[months].' bulan '.$a[days].' hari '.$a[hours].' jam '.$a[minutes].' menit '.$a[seconds].' detik';
?>
kodeing diatas akan menghasilkan contoh output seperti gambar dibawah ini :tanggal 1= 1989-06-06
tanggal 2=2010/11/28 07:11:54
selisih =21 tahun 5 bulan 24 hari 8 jam 11 menit 54 detik
0 komentar on kode untuk menghitung Rentang/Selisih Tanggal :
Posting Komentar