What function can be used to update a post's post date and time to the current date & time?

2 Answers 2


Call wp_update_post() with a special value for 'post_date' and 'post_date_gmt':

$time = current_time('mysql');

    array (
        'ID'            => 123, // ID of the post to update
        'post_date'     => $time,
        'post_date_gmt' => get_gmt_from_date( $time )
  • This answer is still valid in 2021.
    – Will
    Jan 5, 2021 at 18:11
  • Super helpful and simple. Thanks!
    – Garconis
    Feb 26, 2021 at 19:21

The selected answer is perfect for modifying the "publish date", but in my case I wanted to change the "last modified" date (post_modified and post_modified_gmt in the db). The following is sufficient for that:

wp_update_post( [ 'ID' => $id ] );

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.