Created
November 6, 2014 13:22
-
-
Save KaduNovoK/805c151101d18f4ffcf3 to your computer and use it in GitHub Desktop.
DateTime use sample into symfony2 with Doctrine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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