Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Display a list of recent topics


kevinjohngallagher
Member

@kevinjohngallagher

I’m writing this from an mobile phone so apologies if you have to double check the code:

$post_timestamp = strtotime( $result->topic_start_time );

$current_timestamp = time();

$time_difference_in_seconds = $current_timestamp – $post_timestamp;

$number_of_seconds_in_24_hours = 86400;

if($time_difference_in_seconds < $number_of_seconds_in_24_hours)

{

echo date(“H:i a”t, $post_timestamp) ;

} else {

echo date(“jS F”, $post_timestamp) ;

}

Its the long winded way of writing things, but I find its slightly easier to follow what’s going on. Oh and you probably don’t need to assinn all the variables, i just did it so i didn’t have to comment the code :)

Skip to toolbar