PHP:以格式月份年份的形式获取最近6个月的数据 [英] PHP: get last 6 months in format month year
本文介绍了PHP:以格式月份年份的形式获取最近6个月的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
PHP中是否可以通过以下格式获取当前和前五个月的信息?
Is there a way in PHP to get the current and the previous 5 months in the following format?
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
推荐答案
您是否尝试过以下操作:
Have you tried following:
<?php
echo date('F, Y');
for ($i = 1; $i < 6; $i++) {
echo date(', F Y', strtotime("-$i month"));
}
如果这不起作用,请告诉我.
Let me know, if this wont work.
这篇关于PHP:以格式月份年份的形式获取最近6个月的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文