开发者

PHP date calculate

Here is what i try to get. i need the date format in php as this : 2009-11-29

$startdate = (date("Y")-1) .'-'. date("n") .'-'. (date("j")-1);
$enddate = date("Y") .'-'. date("n") .'-'. (date("j")-1);
$myAnalytics->setDateRange($startdate,$enddate);    
echo 'Statistiques entre : ' . $startdate .' et ' . $enddate . '<br/><br/>';

i can get the current date, but i need to get the yesterday date (for google analytic)

so if today is 2009-11-29 removing 1 from 29 get me 28 but as today we are the 2009-12-01 i get the 0 as day...

I need to get the whole date, and remove one day, ans still get a valid date

t开发者_运维知识库hanks


You can use date('Y-n-j', strtotime('yesterday'));

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜