SQL based on the format $ curr_time-> ('Ymd H: i')

Why is this code ...

$curr_time = new DateTime();
$query_inprocess = "UPDATE `MyTable` 
                    SET inprocess=1 
                    WHERE startTime <= '" .$curr_time->format('Y-m-d H:i') . "'";

... leads to an invalid SQL query in which the after statement is <ignored?

UPDATE `MyTable` SET inprocess=1 WHERE startTime <
+5
source share
2 answers

Find below:

"UPDATE `MyTable` SET inprocess=1 WHERE startTime <= now()"

This can help you get the exact result you need.

+1
source

try it

$curr_time = new DateTime();
$query_inprocess = "UPDATE `MyTable` 
                    SET inprocess=1 
                    WHERE startTime <='" .$curr_time->format('Y-m-d H:i'). "'";//OR use date('Y-m-d H:i') instead of $curr_time->format('Y-m-d H:i')
0
source

All Articles