RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
php怎么获取几月后的日期

本教程操作环境:windows7系统、php7.1版、DELL G3电脑

创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:网站设计、网站建设、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的麒麟网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

php怎么获取几月后的日期

实现步骤:

  • 使用strtotime() 函数进行日期的加减运算,获取几月后的时间戳。

  • 使用date() 函数格式获取的时间戳,将其转为指定的时间日期格式。

实现代码:

";
echo "格式化当前时间戳:".date("Y-m-d H:i:s",strtotime("now"))."

"; echo "1个月后的时间戳:".strtotime("+1 month")."
"; echo "格式化时间戳:".date("Y-m-d H:i:s",strtotime("+1 month"))."

"; echo "当前时间戳后2个月:".date("Y-m-d H:i:s",strtotime("+2 month"))."
"; echo "当前时间戳后3天:".date("Y-m-d H:i:s",strtotime("+3 month"))."
"; echo "当前时间戳后4天:".date("Y-m-d H:i:s",strtotime("+4 month"))."
"; ?>

说明:

PHP strtotime() 函数有两种用法:一种是将字符串形式的、用英文文本描述的日期时间解析为 UNIX 时间戳,一种是用来计算一些日期时间的间隔。

strtotime() 函数的使用示例如下:

";
echo strtotime("10 September 2000"), "
"; echo strtotime("+1 day"), "
"; echo strtotime("+1 week"), "
"; echo strtotime("+1 week 2 days 4 hours 2 seconds"), "
"; echo strtotime("next Thursday"), "
"; echo strtotime("last Monday"), "
"; ?>


网页标题:php怎么获取几月后的日期
文章路径:http://www.jxjierui.cn/article/dhsegpc.html