使用Doctrine2在数据库中保留日期

I'm working with Symfony2 and Doctrine2 and I have a class called Domains with properties some names - strings and some dates. I use the following code to persists the information to the database:

public function createAction()
{
    $date = new \DateTime();
    $domain = new Domains();
    $domain->setMainDomain('new domain');
    $domain->setUser('new user');
    $domain->setSrv('server1');
    $domain->setStartDate($date->setDate(1992, 6, 3));
    $domain->setDueDate($date->setDate(1998, 7, 21));
    $domain->setPrevStartDate($date->setDate(1800, 9, 15));
    $domain->setPrevDueDate($date->setDate(1850, 10, 25));
    $domain->setNotified($date->setDate(2222, 3, 21), $date->setTime(12,01));

    $em = $this->getDoctrine()->getEntityManager();
    $em->persist($domain);
    $em->flush();

    return new Response('Added a new domain with number '.$domain->getId());
} 

The problem is that all the dates has the value of the last one in the list :( In the example all of the dates become 2222-03-21. Can you please help me to fix this without creating a new DateTime object for every date which I want to persist in the datebase? Thank you very much in advance!

This is not a Symfony2/Doctrine2 problem.

In PHP all objects are passed by reference, so you're essentially passing around same instance of the $date, so obviously it will set all dates to last one.

There's no way to do this the way you want (using only 1 DateTime instance), but I really don't see a reason why would you want to anyway.

To elaborate, why do you think this:

$domain->setStartDate($date->setDate(1992, 6, 3));
$domain->setDueDate($date->setDate(1998, 7, 21));
$domain->setPrevStartDate($date->setDate(1800, 9, 15));
...

is better than this:

$domain->setStartDate(new \DateTime('1992-6-3'));
$domain->setDueDate(new \DateTime('1998-7-21'));
$domain->setPrevStartDate(new \DateTime('1800-9-15'));
...