全部按月减少一个月?
在此循环中将月份减少一个。
$twitter_val7 .='{
date: new Date('.date("Y",strtotime($date)).', '.date("m",strtotime($date)).', '.date("d",strtotime($date)).'),
value: '.$result_twitter->counts.'
},';
全部按月减少一个月?
在此循环中将月份减少一个。
$twitter_val7 .='{
date: new Date('.date("Y",strtotime($date)).', '.date("m",strtotime($date)).', '.date("d",strtotime($date)).'),
value: '.$result_twitter->counts.'
},';
要使用strtotime()
1个月减少你从字面上告诉它以一个月为下降:
strtotime($date . ' - 1 month');
假设,当然,这$date
是一种格式strtotime()
理解。
我会做这样的..我猜$date
会去代替'2000-01-01'
:
$initial = new DateTime('2000-01-01');
$interval = new DateInterval('P1M');
$newdate = $initial->sub($interval);
echo $newdate->format('Y-m-d H:i:s');
要使用的strtotime
$date='2014-09-03';
$numMonth=1;//here you can pass no. of month
$resultDate=date('Y-m-d',strtotime($date . " - $numMonth month"));
请先了解问题,6票表决答案问题永远不会出错 – 2014-09-04 07:06:09
我不是说6票表决答案错误,但它是另一种减少月份的方法。 $ numMonth用作动态并返回yyyy-mm-dd格式的日期。 – vineet 2014-09-24 09:53:10
看出来这个功能减退月!它并不是真的减去1个月,而是30天。 5月31日将最终为5月01日 – RJD22 2012-05-31 12:05:12