Skip to content

Instantly share code, notes, and snippets.

@LucaRosaldi
Created July 24, 2012 13:08
Show Gist options
  • Save LucaRosaldi/3169842 to your computer and use it in GitHub Desktop.
Save LucaRosaldi/3169842 to your computer and use it in GitHub Desktop.
PHP: Estimated Reading Time
<?php
// http://briancray.com/posts/estimated-reading-time-web-design/
$mycontent = $post->post_content; // wordpress users only
$word = str_word_count(strip_tags($mycontent));
$m = floor($word / 200);
$s = floor($word % 200 / (200 / 60));
$est = $m . ' minute' . ($m == 1 ? '' : 's') . ', ' . $s . ' second' . ($s == 1 ? '' : 's');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment