Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
请我希望减去日期以在同等月份获得我的结果。
$date1 = 01/01/2013; $date2 = 12/12/2013; $months = $date2 - $date1; $months would be 12.
请协助。谢谢
您的日期格式不明确。是DD/MM/YYYY还是MM/DD/YYYY。假设DD/MM/YYYY:
DD/MM/YYYY
MM/DD/YYYY
$date1 = DateTime::createFromFormat('d/m/Y', '01/01/2013'); $date2 = DateTime::createFromFormat('d/m/Y', '12/12/2013'); $interval = $date1->diff($date2); echo $interval->m;
看到它在行动