How to have difference between two dates PHP

87 views Asked by At

I have a switch case with different dates.

        switch($date){
        case 'lastweek':
            $this->setdate(date('Y-m-d',mktime(0, 0, 0, 11, 7, 2014)));
            $this->get();
            break;
        case 'thisweek':
        $now = new DateTime('2010-11-17');
        $after = new DateTime('2010-11-21');
        $interval = $after->diff($now);

            $this->setdate($interval);**
            $this->get();
            break;
        case 'nextweek':
            $this->setdate(date('Y-m-d',mktime(0, 0, 0, 11, 21, 2014)));
            $this->get();
            break;
    } 

With that, I have pictures who are coming according the the date. By the way, when the date is "this week" I want the picture staying until the next date ("nextweek"). I tried something as you can see with the $interval but it doesn't work.

Does someone have an idea?

0

There are 0 answers