Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter 正在尝试从日期中删除1个月_Codeigniter - Fatal编程技术网

Codeigniter 正在尝试从日期中删除1个月

Codeigniter 正在尝试从日期中删除1个月,codeigniter,Codeigniter,我在看别人的代码。基本上,代码的目的是提取这个月的数据和前几个月的数据 今天,它显示七月为本月,七月为上月。我怀疑是因为今天是7月31日,而不是6月31日 下面是定义上个月的代码-有什么想法吗 $this->monthPrev = date('F Y', strtotime('this month -1 month')); $this->currentMonth = date('F Y', strtotime('this month')); 要获取上个月的日期,请尝试以下操作

我在看别人的代码。基本上,代码的目的是提取这个月的数据和前几个月的数据

今天,它显示七月为本月,七月为上月。我怀疑是因为今天是7月31日,而不是6月31日

下面是定义上个月的代码-有什么想法吗

$this->monthPrev    = date('F Y', strtotime('this month -1 month'));
$this->currentMonth = date('F Y', strtotime('this month'));

要获取上个月的日期,请尝试以下操作:

echo date('F Y', strtotime(date('F Y')." -1 month"));
它将返回:

June 2019

您希望获得哪种输出?请澄清。