Kalkulasi Tanggal WAKTU di PHP

Berikut ini adalah contoh kalkulasi tanggal dan waktu di pemrograman PHP

$date1 = "2007-03-24";
$date2 = "2009-06-26";

$diff = abs(strtotime($date2) - strtotime($date1));

$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));

printf("%d years, %d months, %d days\n", $years, $months, $days);

Sumber http://stackoverflow.com/questions/676824/how-to-calculate-the-difference-between-two-dates-using-php

Leave a Reply

Your email address will not be published. Required fields are marked *



*