Reputation: 9293
column later
is datetime
and some fields have the value 2017-05-01 04:07:00
.
I want to change some fields in the rows where current date and time is greater then later
value.
The purpose is to publish a post which has being setting to publish later.
$current = date('Y-m-d H:i:s');
$sql = "update posts set status = :astatus, user = :auser, pass = :apass where later < :alater";
$stmt = $db->prepare($sql);
$stmt->execute(array(
":astatus" => 'public',
":auser" => '',
":apass" => '',
":alater" => $current
));
Nothing is changed.
Upvotes: 0
Views: 59
Reputation: 123
suppose i have to show post after one hrs from the posting time I simply use cron job
suppose i have post sr from location to location created date 1 Pune Nagpur 2017-07-29 05:00:00
I have to show this post at 2017-07-29 06:00:
simply i run cron job in the interval of 5 minute check whether created time is current time if yes the show and maintain sum flag .
Upvotes: 0
Reputation: 1269773
Instead of passing the time in, use the database time:
$sql = "update posts set status = :astatus, user = :auser, pass = :apass where later < now()";
$stmt = $db->prepare($sql);
$stmt->execute(array(
":astatus" => 'public',
":auser" => '',
":apass" => ''
));
Upvotes: 1