PHP:最简单的方法来获取第一个月前6个月的日期? [英] PHP: simplest way to get the date of the month 6 months prior on the first?

查看:283
本文介绍了PHP:最简单的方法来获取第一个月前6个月的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以如果今天是2010年4月12日,
应该会返回2009年10月1日

So if today was April 12, 2010 it should return October 1, 2009

我用Google搜索的某些可能的解决方案似乎过于复杂,任何建议?

Some possible solutions I've googled seem overly complex, any suggestions?

推荐答案

嗯,也许是这样;

echo date("F 1, Y", strtotime("-6 months"));

编辑;

指定自定义日期用途;

if you would like to specify a custom date use;

echo date("F, 1 Y", strtotime("-6 months", strtotime("Feb 2, 2010")));

这篇关于PHP:最简单的方法来获取第一个月前6个月的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆