包含当前月份的所有日期的Php数组 [英] Php array containing all dates of the current month
本文介绍了包含当前月份的所有日期的Php数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
尝试:
($ i = 1; $ i< = date('t'); $ i ++)
{
/ /将日期添加到日期数组
$ dates [] = date('Y')。 - 。日期('m')。 - 。 str_pad($ i,2,'0',STR_PAD_LEFT);
}
//显示日期数组
var_dump($ dates);
I'm trying and still wondering, how I can get an array which contains all of the dates in the current month, it should contain all of the dates in format: year-month-day. Thanks for your help!
解决方案
Try:
// for each day in the month
for($i = 1; $i <= date('t'); $i++)
{
// add the date to the dates array
$dates[] = date('Y') . "-" . date('m') . "-" . str_pad($i, 2, '0', STR_PAD_LEFT);
}
// show the dates array
var_dump($dates);
这篇关于包含当前月份的所有日期的Php数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文