You can get the post’s creation date/time and compare it to the current date/time.
global $post;
$now = time(); // Current time in seconds since Epoch
$post_created = strtotime( $post->post_date ); // post's creation date in seconds since Epoch, so we're comparing apples to apples
$one_day_in_seconds = 24*60*60;
if ( ( $now - $post_created ) < $one_day_in_seconds ) {
echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago';
} else {
the_time( 'F j, Y \a\t g:i a' );
}
References
PHP.net:
time()
strtotime()
Codex:
Post Object (for the post_date
)