Search code examples
phptimesymfony1

Symfony Expiration Time Calculation


InSymfony (Doctrine) I am trying to create a public function with the code below. What I'm trying to do is when a user submits a form, it calculated the expiration date for the item. Here is the code I have so far but I don't know how to calculate the current time. I have taken pieces of code from different examples I have found on the internet but it fails every time.

class Car extends BaseCar
{
    public function save(Doctrine_Connection $conn = null)
    {

    if ($this->isNew() && ! $this->getEndtime()) 
        {
            $now = THIS IS WHAT I NEED HELP WITH
            $this->setEndtime(date('Y-m-d H:i:s', $now + 86400 * sfConfig::get('item_duration')));
        }
        return parent::save($conn);
    }

}

The item_duration is set in the App.yml file. So I can set it as a site wide variable.


Solution

  • You can get the current time with this.

    $now = time();