WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my theme, I'd like to display the publish date and (only) if the post was updated after the publish date, also display the updated date. The code in my theme now looks like this:

*/ stuff above here to display publish date, then do this stuff to see if updated */
if ( get_the_date() != get_the_modified_date() )
        printf( __( '<br>Updated: <time class="entry-date" datetime="%1$s">%2$s</time>', 'splatone' ),
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() )

If the post was published and updated on the same day, I'd rather not show the updated line, but it currently is. How can I compare the dates so that I only get it if the date has changed and not just the time?

share|improve this question
up vote 1 down vote accepted

get_the_date() and get_modified_date() don't return time values: so, if you change your conditional statement to the below, it should work:

if ( get_the_modified_date() > get_the_date() )

Now if the updated date is greater than the original publish date(by one day), the if statement is true.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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