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.
我正在寻找一种方法来计算从特定日期到今天已经过去的月份。例如,从一月到今天(六月)将是“5”
请记住,如果一年后它应该可以工作,所以必须包括这一年。
使用 date_diff()
$df = date_diff(date_create('01/08/2012'),date_create('05/08/2012')); echo $df->format("Month: %M");