Answer the question
In order to leave comments, you need to log in
How to write current date in sql (createquerybuilder)?
How to write current date in sql (createquerybuilder) symfony 5?
I try the following options, but they do not work. (datetime type)
$this->createQueryBuilder('t')
->update()
->set('t.status', 1)
->set('t.ok_date', new \DateTime('now'))
->where('t.id = :t_id')
->setParameter('t_id', $t_id)
$this->createQueryBuilder('t')
->update()
->set('t.status', 1)
->set('t.ok_date', 'NOW()')
->where('t.id = :t_id')
->setParameter('t_id', $t_id)
Answer the question
In order to leave comments, you need to log in
1. ->set('t.ok_date', new \DateTime('now')->format('Ymd h:i:s'))
2. ->setParameter('ok_date', new \DateTime('now '), \Doctrine\DBAL\Types\Type::DATETIME)
3. Why not do it with an object? What for for such nonsense to climb in qb?
I usually create a variable
$now = new \DateTime(date('Ymd H:i:s'));
and then I stick this $now in the right place
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question