Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2. class TimeDiff {
  3.  
  4. public $month;
  5. public $day;
  6. public $year;
  7. public $hour;
  8. public $minute;
  9. public $second;
  10.  
  11. function __construct($year, $month, $day, $hour, $minute, $second) {
  12.     $this->month = $month;
  13.     $this->day = $day;
  14.     $this->year = $year;
  15.     $this->hour = $hour;
  16.     $this->minute = $minute;
  17.     $this->second = $second;
  18. }
  19.  
  20. function TimeTo() {
  21.    
  22.     $m = $this->month;
  23.     $d = $this->day;
  24.     $y = $this->year;
  25.     $ho = $this->hour;
  26.     $mi = $this->minute;
  27.     $se = $this->second;
  28.    
  29.     $mn = date("m");
  30.     $dn = date("d");
  31.     $yn = date("y");
  32.     $hh = date("H");
  33.     $mm = date("i");
  34.     $ss = date("s");
  35.     $diff = mktime($ho,$mi,$se,$m,$d,$y)-mktime($hh,$mm,$ss,$mn,$dn,$yn);
  36.     $days = $diff/60/60/24;
  37.     $hours = $diff/60/60 - intval($days)*24;
  38.     $minutes = $diff/60 - intval(intval($days*24)*60);
  39.     $seconds = $diff - intval(intval(intval($days*24*60))*60);
  40.  
  41.     $text.= round($days);
  42.     $mins = round($days)."";
  43.     if ($mins == "11" or $mins == "12" or $mins == "13" or $mins == "14") $text.= " суток "; else
  44.     if (
  45.         $mins[strlen($mins)-1] == "2"
  46.         or $mins[strlen($mins)-1] == "3"
  47.         or $mins[strlen($mins)-1] == "4")
  48.         $text.= " суток "; else
  49.     if($mins[strlen($mins)-1] == "1")
  50.         $text.= " сутки "; else
  51.         $text.= " суток ";
  52.  
  53.         $text.= round($hours);
  54.     if (round($hours) == 1 or round($hours == 21)) $text.= " час "; else
  55.     if (round($hours) == 2 or round($hours) == 3 or round($hours) == 4 or round($hours) == 22 or round($hours) == 23) $text.= " часа ";
  56.     else $text.= " часов ";
  57.  
  58.     $text.= round($minutes);
  59.  
  60.     $mins = round($minutes)."";
  61.     if ($mins == "11" or $mins == "12" or $mins == "13" or $mins == "14") $text.= " минут "; else
  62.     if (
  63.         $mins[strlen($mins)-1] == "2"
  64.         or $mins[strlen($mins)-1] == "3"
  65.         or $mins[strlen($mins)-1] == "4")
  66.         $text.= " минуты "; else
  67.     if($mins[strlen($mins)-1] == "1")
  68.     $text.= " минута "; else
  69.     $text.= " минут ";
  70.  
  71.     /*$text.= round($seconds);
  72.     $mins = round($seconds)."";
  73.     if ($mins == "11" or $mins == "12" or $mins == "13" or $mins == "14") $text.= " секунд "; else
  74.     if (
  75.         $mins[strlen($mins)-1] == "2"
  76.         or $mins[strlen($mins)-1] == "3"
  77.         or $mins[strlen($mins)-1] == "4")
  78.         $text.= " секунды "; else
  79.     if($mins[strlen($mins)-1] == "1")
  80.     $text.= " секунда "; else
  81.     $text.= " секунд ";*/
  82.  
  83. return $text;
  84. }
  85. }
  86. ?>