tags:

views:

80

answers:

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

thanks

+5  A: 

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

Jacob Relkin
You'll probably want 'Y-n-j' (without the spaces) to get the exact form listed.
PeterJCLaw
p-e-r-f-e-c-t that work great WITHOUT space !
marc-andre menard