SHARE
TWEET

Untitled

a guest Jul 21st, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function HumanDate($date) {
  2.     $date = strtotime($date);
  3.     $diff = time() - $date;
  4.  
  5.     if ($diff < 0) {
  6.       $days = ceil($diff / 86400);
  7.     } else {
  8.       $days = floor($diff / 86400);
  9.     }
  10.     $hd = '';
  11.     if ($days == 0) {
  12.       $hd = 'сегодня в ' . date('H:i', $date);
  13.     } else {
  14.       if ($days > 0) {
  15.         switch ($days) {
  16.           case 1:
  17.             $hd = 'вчера в ' . date('H:i', $date);
  18.             break;
  19.           case 2:
  20.             $hd = 'позавчера в ' . date('H:i', $date);
  21.             break;
  22.         }
  23.       } else {
  24.         switch ($days) {
  25.           case -1:
  26.             $hd = 'завтра в ' . date('H:i', $date);
  27.             break;
  28.           case -2:
  29.             $hd = 'послезавтра в ' . date('H:i', $date);
  30.             break;
  31.           case -3:
  32.             $hd = 'через три дня';
  33.             break;
  34.         }
  35.       }
  36.     }
  37.     if ($hd == '') {
  38.       $hd = date('d.m.Y H:i', $date);
  39.     }
  40.     return '<acronym title="' . date('d.m.Y H:i', $date) . ', ' . self::$weekdays[date('N', $date)] . '">' . $hd . '</acronym>';
  41. }
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