what’s new in the Brotherson world
RSS icon Home icon
  • time of day hack for b2evolution

    Posted on December 26th, 2004 Matt Brotherson No comments

    I stumbled upon a hack for wordpress that replaces the actual post time with a 'time of day' verbiage and ported it over to b2evolution. The modification is rather easy.

    First place this function in your conf/_hacks.php:

    PHP:
    1. <?php
    2. // inputs must be unix timestamp (seconds)
    3. function time_of_day($pdate){
    4. global $DB, $tableposts;
    5. $hour=date('H',$pdate);
    6. switch($hour)
    7. {
    8. case 0:
    9. case 1:
    10. case 2:
    11. $tod = 'the wee hours';
    12. break;
    13. case 3:
    14. case 4:
    15. case 5:
    16. case 6:
    17. $tod = 'terribly early in the morning';
    18. break;
    19. case 7:
    20. case 8:
    21. case 9:
    22. $tod = 'early morning';
    23. break;
    24. case 10:
    25. $tod = 'mid-morning';
    26. break;
    27. case 11:
    28. $tod = 'late morning';
    29. break;
    30. case 12:
    31. case 13:
    32. $tod = 'lunch time';
    33. break;
    34. case 14:
    35. $tod = 'early afternoon';
    36. break;
    37. case 15:
    38. case 16:
    39. $tod = 'mid-afternoon';
    40. break;
    41. case 17:
    42. $tod = 'late afternoon';
    43. break;
    44. case 18:
    45. case 19:
    46. $tod = 'early evening';
    47. break;
    48. case 20:
    49. case 21:
    50. $tod = 'evening time';
    51. break;
    52. case 22:
    53. $tod = 'late evening';
    54. break;
    55. case 23:
    56. $tod = 'late at night';
    57. break;
    58. default:
    59. $tod = '';
    60. break;
    61. }
    62. //return $tod;
    63. echo $tod;
    64. }?>

    Then in your skin's _main.php file, replace your post time section with this:

    PHP:
    1. <?php time_of_day(abs(strtotime($Item-&gt;issue_date))); ?>

    You can add some css to display this image right before the time: clock image.

    Preview here: http://brotherson.com/index.php?skin=simple

    Leave a reply