I am not much of a coder but I have done research lately on how to change the post date and time in WordPress to the current date and time for all posts and I have not been able to get much.

If anyone can help me, I will greatly appreciate it. Thanks.

1 Answer 1


I know you said you are not a programmer so this is probably not an easy fix. This is not something that is easy to do without either permanently changing the date / time in the database and they it will be the date / time that you set it as, or go through your theme files and update them. Here is one way to do it if you have access to your phpmyadmin panel Backup your database first please. Run an sql command:

UPDATE wp_posts SET post_date = NOW(), post_date_gmt = NOW() WHERE post_type = 'post';

This is irreversible and all posts will be updated with the current date / time. Another way to do it is go through your theme's template file and look for the date / time snippets of code and replace them with the current date and time. You can put this function in your functions.php file and call it

function wpb_display_current_datetime() {
    $current_datetime = current_time('Y-m-d H:i:s');
    echo 'Current Date and Time: ' . $current_datetime;

then in your theme file replace the date and time wiht this:

<?php echo wpb_display_current_datetime(); ?>


echo wpb_display_current_datetime();

Backup your site before you try.

If you add this code to your theme's functions.php file it will append the current date / time to your posts

function wpb_add_current_datetime_to_posts($content) {
    // Check if we're inside the main loop in a single post page.
    if (is_single() && in_the_loop() && is_main_query()) {
        $current_datetime = current_time('Y-m-d H:i:s');
        $datetime_display = '<p>Current Date and Time: ' . $current_datetime . '</p>';

        // Append the date and time to the content
        $content = $datetime_display . $content;

    return $content;

add_filter('the_content', 'wpb_add_current_datetime_to_posts');

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.