If modified on same day, show only time

I have a date on each post and comment which shows the date of placement.

If I edit it, it shows me the date of the post and the modified date. That’s fine, but now, I want to show only the post date AND the TIME of the modified date only if the post is edited on the same day as it’s posted.

Read More

So for example:

If a post is has been submitted on 8 march 2013 15:00, show me: 08-03-2013 15:00
If a post is edited on 8 march 2013 16:30, show me: 08-03-2013 15:00 - 16:30
If a post is edited on 9 march 2013 17:00, show me: 08-03-2013 15:00 - 09-03-2013 17:00

How can I do this? I am using something like this, except for the AM and PM.

<?php the_modified_date('F j, Y'); ?> at <?php the_modified_date('g:i a'); ?>

How can I only show the time if it’s modified on the same date?

Related posts

1 comment

  1. Give this a try:

    if(get_the_modified_date('zY')==date('zY')) {  
    the_modified_date('g:i a'); 
    } else {
    the_modified_date('F j, Y'); echo ' at '; the_modified_date('g:i a');
    }
    

    It checks that the modified date is the current day. If it is, it only displays the modified time. Otherwise it displays both the date and time.

Comments are closed.