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

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));
    $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' );
share|improve this question
up vote 3 down vote accepted
$mytimestamp = date(get_option('date_format'), strtotime($date)) . ' at ' . date(get_option('time_format'), strtotime($date));   
share|improve this answer
Works perfectly thanks! – Rob Jan 6 '12 at 13:35

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.