PHP至今增加1个月

编程入门 行业动态 更新时间:2024-10-25 19:32:28
本文介绍了PHP至今增加1个月的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个函数返回1个月前的网址。

我想显示当前选定的月份,但是我不能使用简单的当前月份当用户点击链接到1个月后,选择的月份将更改,并且将不会是当前的。

因此,函数返回2012年8月

/ p> $ p $ p $ p $ b

<?php echo strip_tags(tribe_get_previous_month_text()); ?>

解决方案

简单方法:

$ next_month = strtotime('下个月'八月2012');

更好的方法:

$ d = new Date('August 2012'); $ next_month = $ d-> add(new DateInterval('P1M'));

相关文档: strtotime date dateinterval

I've a function that returns url of 1 month before.

I'd like to display current selected month, but I cannot use simple current month, cause when user clicks link to 1 month back selected month will change and will not be current.

So, function returns August 2012

How do I make little php script that adds 1 month to that?

so far I've:

<?php echo strip_tags(tribe_get_previous_month_text()); ?>

解决方案

simple method:

$next_month = strtotime('august 2012 next month');

better method:

$d = new Date('August 2012'); $next_month = $d->add(new DateInterval('P1M'));

relevant docs: strtotime date dateinterval

更多推荐

PHP至今增加1个月

本文发布于:2023-11-22 09:47:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616945.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:个月   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!