📜  如何在 codeigniter 中获取日期差异 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:40.555000             🧑  作者: Mango

代码示例1
$date1 = date("Y-m-d",strtotime($_POST['customer_birth']));
$date2 = date("Y-m-d",strtotime($_POST['customer_marriage']));

$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));