Skip to content

Instantly share code, notes, and snippets.

@KaduNovoK
Created November 6, 2014 13:22
Show Gist options
  • Save KaduNovoK/805c151101d18f4ffcf3 to your computer and use it in GitHub Desktop.
Save KaduNovoK/805c151101d18f4ffcf3 to your computer and use it in GitHub Desktop.
DateTime use sample into symfony2 with Doctrine
<?php
//... some code
public function findByFieldIntoInterval(\DateTime $earlyDate, \DateTime $lateDate)
{
$qb = $this->createQueryBuilder('e');
$qb->where($qb->expr()->between('e.field', ':earlyDate', ':lateDate'));
$qb->setParameter('earlyDate', $earlyDate, \Doctrine\DBAL\Types\Type::DATETIME);
$qb->setParameter('lateDate', $lateDate, \Doctrine\DBAL\Types\Type::DATETIME);
return $qb->getQuery()->getResult();
}
// ... some code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment