0

I want to update my wordpress posts based on exact time including hours, minutes and seconds, I tried the simple where clause, it seems ignoring the minutes and seconds, here is my simple query:

$date = '2023-05-16 07:28:31'; $res = $wpdb->get_results("SELECT ID FROM wp_posts where post_date = '".$date."'"); The result in this case return all the records with 2023-05-16

but I want only the posts with the exact time.

1
  • is there a reason this is being done using raw SQL and not WP_Query and the date parameters? If you're going to do raw SQL you should use $wpdb->prepare to insert the variables rather than doing it directly so that it's safer
    – Tom J Nowell
    May 17, 2023 at 9:41

1 Answer 1

0

Try $date = '2023-05-16T07:28:31';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.