The Post Date in WordPress

WordPress Templates

Post Time

Get the time the post was published with get_the_time().

<?php echo get_the_time('F jS, Y'); ?>

Post Time Advanced

// Get the numberr of seconds past since the post was published.
$total_seconds_since_pub = current_time('timestamp') - get_the_time('U');

// Test if the post is older than 2 weeks.
if ($total_seconds_since_pub < 1209600) {

    // Print the time since the post was pubished.
    echo str_replace('mins', 'minutes', human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago');
} else {

    // Print the date and time the post was pubished.
    echo get_the_time('F jS, Y');
}