SHARE
TWEET

Untitled

a guest Jun 20th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static function getAgo($date) {
  2.  
  3.     if ($date) {
  4.  
  5.         $ts = time() - strtotime(str_replace("-","/",$date));
  6.  
  7.         if($ts>31536000) $val = round($ts/31536000,0).' year';
  8.         else if($ts>2419200) $val = round($ts/2419200,0).' month';
  9.         else if($ts>604800) $val = round($ts/604800,0).' week';
  10.         else if($ts>86400) $val = round($ts/86400,0).' day';
  11.         else if($ts>3600) $val = round($ts/3600,0).' hour';
  12.         else if($ts>60) $val = round($ts/60,0).' minute';
  13.         else $val = $ts.' second';
  14.  
  15.         if($val>1) $val .= 's';
  16.  
  17.         return $val;
  18.  
  19.  
  20.     }
  21.  
  22. }
  23.      
  24. {{ DateHelper::getAgo($log->createdAt) }}
  25.      
  26. <?php use AppDateHelper; ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top