开发者

PHP date calculate

开发者 https://www.devze.com 2022-12-13 11:45 出处:网络
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);

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

精彩评论

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