<?php
$date1
=
strtotime
(
"2016-06-01 22:45:00"
);
$date2
=
strtotime
(
"2018-09-21 10:44:01"
);
$diff
=
abs
(
$date2
-
$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));
$hours
=
floor
((
$diff
-
$years
* 365*60*60*24
-
$months
*30*60*60*24 -
$days
*60*60*24)
/ (60*60));
$minutes
=
floor
((
$diff
-
$years
* 365*60*60*24
-
$months
*30*60*60*24 -
$days
*60*60*24
-
$hours
*60*60)/ 60);
$seconds
=
floor
((
$diff
-
$years
* 365*60*60*24
-
$months
*30*60*60*24 -
$days
*60*60*24
-
$hours
*60*60 -
$minutes
*60));
// Print the result
printf(
"%d years, %d months, %d days, %d hours, "
.
"%d minutes, %d seconds"
,
$years
,
$months
,
$days
,
$hours
,
$minutes
,
$seconds
);
?>
No comments:
Post a Comment