Posted By

Kerrick on 03/31/11


Tagged


Versions (?)

News Items


 / Published in: PHP
 

Date_Difference::getStringResolved simply makes a pretty date of "Yesterday," "Five minutes ago," "Last Week," etc.

  1. <?php
  2. include('includes/prettydate.php');
  3. $newsitems = array(
  4. "link" => "http://www.semo.edu/news/index_32717.htm",
  5. "title" => "Lisa Ling Speaking Engagement Canceled at Southeast",
  6. "iso_date" => "2011-01-27",
  7. ),
  8. "link" => "http://www.semo.edu/news/index_32707.htm",
  9. "title" => "Jazz Series Presents Gala Festival Concert with Jazz Trombonist Tony Baker",
  10. "iso_date" => "2011-01-27",
  11. ),
  12. "link" => "http://www.semo.edu/news/index_32686.htm",
  13. "title" => "Ribbon Cutting Ceremony Planned for Beef Research Facility",
  14. "iso_date" => "2011-01-27",
  15. ),
  16. "link" => "http://www.semo.edu/news/index_32684.htm",
  17. "title" => "'The Arrow' to Commemorate Its 100th Anniversary in Upcoming Edition",
  18. "iso_date" => "2011-01-26",
  19. ),
  20. "link" => "http://www.semo.edu/news/index_32675.htm",
  21. "title" => "Southeast to Host 'Show Me Day' Feb. 19 for Prospective Students and Parents",
  22. "iso_date" => "2011-01-25",
  23. )
  24. );
  25. ?>
  26. <ol>
  27. <?php
  28. foreach ($newsitems as $item) {
  29. echo '<li><a href="'.$item["link"].'"><h3>'.$item["title"].'</h3><time datetime="'.$item["iso_date"].'">'.Date_Difference::getStringResolved($item["iso_date"]).'</time></a></li>';
  30. }
  31. ?>
  32. </ol>

Report this snippet  

You need to login to post a comment.