Re: creating a date array

From: Date: Tue, 25 Mar 2003 14:31:11 +0000
Subject: Re: creating a date array
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-26617@lists.php.net to get a copy of this message
> trying to make an array with every date (in YYYY-MM-DD format) of the > current week in it... > the below code ain't working, any ideas?! > > cheers, > dave > > function createdatearray($sunday){ > $date = date('Ymd',strtotime($date)); > for($x=0; $x<=7; $x++){ > $y = $x + 1; > $date[$y] = mktime(0,0,0,date('m'),date('d')-date('w')+$x > ,date('Y')); > } > return $date; > } It works just fine. You're adding Unix timestamps to $date, though, not a formatted YYYY-MM-DD date. To do that, you need: $date[$y] = date('Y-m-d',mktime(0,0,0,date('m'),date('d')-date('w')+$x ,date('Y'))); ---John Holmes...

« previous php.db (#26617) next »