Home > OS >  How do I compare the date from the user with the date in the database? in symfony
How do I compare the date from the user with the date in the database? in symfony

Time:02-15

I use symfony 4.when i compare date i can only compare years as below not days or months. if it is in different months and days in the same year, it shows equal to each other. i want to compare with days, month and years. "p.createdAt" type is datetime

    if (!empty($filter['startDate'])) {
        $qb->andWhere($qb->expr()->gte('p.createdAt',':startDate'))
        ->setParameter('startDate',$filter['startDate']);
    }

CodePudding user response:

I use code like this:

$qb->andWhere('p.createdAt >= :queryDate')
    ->setParameter('queryDate', $queryDate);

without problem.

  • Related