gpt4 book ai didi

php - 如何在 PHP 中获得 15 天/1 个月后的日期?

转载 作者:IT王子 更新时间:2023-10-28 23:46:13 28 4
gpt4 key购买 nike

在我的 PHP 代码中,我的变量“$postedDate”中有一个日期。
现在我想获取 7 天、15 天、1 个月和 2 个月后的日期。

我应该使用哪个日期函数?

输出日期格式应为美国格式。

最佳答案

使用 strtotime。

$newDate = strtotime('+15 days',$date)

$newDate 现在将在 $date 之后 15 天。 $date 是 unix 时间。

http://uk.php.net/strtotime

关于php - 如何在 PHP 中获得 15 天/1 个月后的日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/828332/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com