根据 php/joomla 中的周期计算日期


Calculate date based on period in php/joomla

>有人知道如何根据周/月/年数计算日期吗?

假设如果我将时间段设置为 2 周,我应该在当前日期后 2 周获得日期。如果周期是 3 周,那么,我应该在当前日期后获得 3 周。月份和年份也是如此。任何人都可以帮助参考代码吗?我无法实现这一点。是否有任何预定义的功能?

我不太清楚你想得到什么,但看看这个答案 joomla.stackexchange.com 看看 PHP 式的日期计算是可能的。 这是关于季度的,但随着时间使用等变化,你应该能够得到你需要的东西。

$date = date("Y-m-d");// current date
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");
$date = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");