RE: creating a date array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You also need to give your array a different name so this should work :

function createdatearray($sunday){
        $date = date('Ymd',strtotime($date));
        for($x=0; $x<=7; $x++){
                $y = $x + 1;
                $date1[$y] =
date('Y-m-d',mktime(0,0,0,date('m'),date('d')-date('w')+$x,date('Y')));
        }
        return $date1;
}

Sincerely

berber

Visit http://www.weberdev.com/ Today!!!
To see where PHP might take you tomorrow.

-----Original Message-----
From: CPT John W. Holmes [mailto:holmes072000@charter.net] 
Sent: Tuesday, March 25, 2003 4:31 PM
To: David Rice; php-db@lists.php.net
Subject: Re:  creating a date array


> 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...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux