【发布时间】:2021-02-11 06:51:13
【问题描述】:
好的,我想弄清楚如何创建函数来获取两个日期之间发票延迟的月数。我尝试了很多小时,但没有成功,我很困惑从哪里开始......
公式如下:
从:1/1/2020 到:10-02-2021
Months 1, 2, 3, 4, 5 (if not paid during this months, we count the number of month starting from the next month.)
count the number of months from the next month, from 6-2020 to 02-2021
result 9;
同样,我们也这样做:
Months: 4, 5, 6, 7, 8
count the number of months from the next month, from 9-2020 to 02-2021
result 6;
7, 8, 9, 10, 11
count the number of months from the next month, from 12-2020 to 02-2021
result 3;
10, 11, 12, 01, 02
count the number of months from the next month, from 3-2021 to 02-2021 (not possible since date end in 10-02-2021
result 0;
所以,最后我们计算月数:
9 + 6 + 3 + 0 = 18
函数应该打印“18”。
提前致谢!
【问题讨论】:
-
Stack Overflow不是免费的代码编写服务。您应该尝试自己编写代码。在doing more research 之后,如果您有问题,您可以发布您尝试过的内容,并清楚地解释什么不起作用,并提供一个minimal reproducible example 。我建议阅读How to Ask 一个好问题和the perfect question。另外,请务必将tour阅读this
标签: php