rendered paste body<?php /** * Name: Smart Time * Description: Think realistically. Everyone likes you when you do :) Note to self: You need to rewrite this function to use CASE instead of elseif statements, because nathan doesn't like it... :| * Usage: $auth->smartTime(timestamp); **/ public function smartTime($timestamp){ // Current timestamp $current_time = time(); // Days $longtime = $timestamp+60*60*24*14; // Two weeks. $week = $timestamp+60*60*24*7; $severaldays = $timestamp+60*60*24*3; $yesterday = $timestamp+60*60*24; // Hours $twelvehours = $timestamp+60*60*12; $tenhours = $timestamp+60*60*10; $ninehours = $timestamp+60*60*9; $eighthours = $timestamp+60*60*8; $sevenhours = $timestamp+60*60*7; $sixhours = $timestamp+60*60*6; $fivehours = $timestamp+60*60*5; $fourhours = $timestamp+60*60*4; $threehours = $timestamp+60*60*3; $twohours = $timestamp+60*60*2; $onehour = $timestamp+60*60; // Minutes $fourtyfive = $timestamp+60*45; $thirty = $timestamp+60*30; $fifteen = $timestamp+60*15; $five = $timestamp+60*5; $four = $timestamp+60*4; $three = $timestamp+60*3; $two = $timestamp+60*2; $one = $timestamp+60; // Seconds $seconds = $timestamp+30; switch($current_time) { case ($current_time > $longtime): $smart_time = date("F jS Y", $timestamp); break; case ($current_time > $week): $smart_time = "A week ago"; break; case ($current_time > $severaldays): $smart_time = "Several days ago"; break; case ($current_time > $yesterday): $smart_time = "Yesterday"; break; case ($current_time > $twelvehours): $smart_time = "12 hours ago"; break; case ($current_time > $tenhours): $smart_time = "10 hours ago"; break; case ($current_time > $ninehours): $smart_time = "9 hours ago"; break; case ($current_time > $eighthours): $smart_time = "8 hours ago"; break; case ($current_time > $sevenhours): $smart_time = "7 hours ago"; break; case ($current_time > $sixhours): $smart_time = "6 hours ago"; break; case ($current_time > $fivehours): $smart_time = "5 hours ago"; break; case ($current_time > $fourhours): $smart_time = "4 hours ago"; break; case ($current_time > $threehours): $smart_time = "3 hours ago"; break; case ($current_time > $twohours): $smart_time = "2 hours ago"; break; case ($current_time > $onehour): $smart_time = "1 hour ago"; break; case ($current_time > $fourtyfive): $smart_time = "45 minutes ago"; break; case ($current_time > $thirty): $smart_time = "30 minutes ago"; break; case ($current_time > $fifteen): $smart_time = "15 minutes ago"; break; case ($current_time > $five): $smart_time = "5 minutes ago"; break; case ($current_time > $four): $smart_time = "4 minutes ago"; break; case ($current_time > $three): $smart_time = "3 minutes ago"; break; case ($current_time > $two): $smart_time = "2 minutes ago"; break; case ($current_time > $one): $smart_time = "1 minute ago"; break; case ($current_time > $seconds): $smart_time = "less than a minute ago"; break; default: $smart_time = "a few seconds ago"; } $this->debug->write(FF, "auth::smartTime({$timestamp}) returned {$smart_time}"); return $smart_time; }?>