Question

I'm using the following custom function to display the timestamp for a post as posted "X minutes ago" or "X days ago" for 14 days and then this changes to the actual date (e.g. 17th December 2010):

add_filter('the_time', 'dynamictime');
function dynamictime() {
  global $post;
  $date = $post->post_date;
  $time = get_post_time('G', true, $post);
  $mytime = time() - $time;
  if($mytime > 0 && $mytime < 14*24*60*60)
    $mytimestamp = sprintf(__('%s ago'), human_time_diff($time));
  else
    $mytimestamp = date(get_option('date_format'), strtotime($date));
  return $mytimestamp;
}

This is called with the standard code:

<?php the_time(); ?>

Is there a way to modify this to also include the time after 14 days so it would display as follows? (only after the 14 days)

17th December 2010 at 9:03pm

I have the extra code needed to do this but can't figure out how to create an array to display both the get_option with the word 'at' in between too:

$date_format = get_option( 'date_format' );
$time_format = get_option( 'time_format' );

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top