<?php
  class TimeDate
  {
      function ConvertTimeToGMT($Time,$GMT)
      {
         $Time = strtotime($Time);
         $Time=$Time-$GMT*60*60; 
         $Time=date('Y-m-d H:i:s',$Time);
         return $Time;    
      }
      
      function AddTimeGMT($Time,$GMT)
      {
         $Time = strtotime($Time);
         $Time=$Time+$GMT*60*60; 
         $Time=date('Y-m-d H:i:s',$Time);
         return $Time;    
      }
      
      function SubtractionTimeAndGMT($Time,$GMT,$Hours=0,$Minuts=0,$Seconds=0)
      {
         $Time=strtotime($Time);
         $Time=$Time-$GMT*60*60-$Hours*60*60-$Minuts*60-$Seconds;
         $Time=date('Y-m-d H:i:s',$Time);
         return $Time;       
      }
      function AdditionTimeAndGMT($Time,$GMT,$Hours=0,$Minuts=0,$Seconds=0)
      {
         $Time=strtotime($Time);
         $Time=$Time-$GMT*60*60+$Hours*60*60+$Minuts*60+$Seconds;
         $Time=date('Y-m-d H:i:s',$Time);
         return $Time;       
      }
      
      function DifferenceTime($Date1,$Date2)
      {
        $Date1=strtotime($Date1);
        $Date2=strtotime($Date2);
        $Residual=$Date1-$Date2;
        $Seconds =  $Residual%60;
        $Min = floor($Residual/60);
        $Minuts = $Min%60;
        $Hourses = floor($Min/60);
        if ($Hourses<10){$Hourses='0'.$Hourses;}
        if ($Minuts<10){$Minuts='0'.$Minuts;}
        if ($Seconds<10){$Seconds='0'.$Seconds;}
        $DifferenceTime=$Hourses.':'.$Minuts.':'.$Seconds;
        return $DifferenceTime;
      }
      
	  function DifferenceTimeSecond($Date1,$Date2)
      {
        $Date1=strtotime($Date1);
        $Date2=strtotime($Date2);
        $Residual=$Date1-$Date2;
       
        return $Residual;
      }
	  
      function SubstractionDate($Time,$Days,$Month=0,$Year=0)
      {
         $Days=$Days*24*60*60;
         $Time=strtotime($Time);
         $Time=$Time-$Days;
         $Time=date('Y-m-d H:i:s',$Time);
         return $Time;
      }
      
      function SubstractionTime($Time,$Hours,$Minuts=0,$Seconds=0)
      {
         $Time=strtotime($Time);
         $Time=$Time-$Hours*60*60-$Minuts*60-$Seconds;
         $Time=date('Y-m-d H:i:s',$Time);
         return $Time;
      }
	  
	  function DifferenceTimeMilesecond($Date1,$Date2)
      {
         $Date1=strtotime($Date1);
         $Date2=strtotime($Date2);
         $Residual=$Date1-$Date2;
         
         return $Residual;      
      }
	  
	  function ConvertMilesecondTime($Date)
      {
        //$Date =  $Date%60;
        $Min = floor($Date/60);
        $Minuts = $Min%60;
        $Hourses = floor($Min/60);
        if ($Hourses<10){$Hourses='0'.$Hourses;}
        if ($Minuts<10){$Minuts='0'.$Minuts;}
        if ($Seconds<10){$Seconds='0'.$Seconds;}
        $convertDate = $Hourses.':'.$Minuts.':'.$Seconds;
        
        return $convertDate;
      }
	  
	  function AddTime($Time1,$Time2)
      {
        $TimeArr1 = explode(':',$Time1);
        $TimeArr2 = explode(':',$Time2);
    
    if (count($TimeArr1) > 1)
    {
        
        $hours = (int)$TimeArr1[0] * 60 * 60;
        $minets = (int)$TimeArr1[1] * 60;
        $seconds = (int)$TimeArr1[2];
        $Time1 = $hours + $minets + $seconds;
    }
    
    
    if (count($TimeArr2) > 1)
    {
        
        $hours = (int)$TimeArr2[0] * 60 * 60;
        $minets = (int)$TimeArr2[1] * 60;
        $seconds = (int)$TimeArr2[2];
        $Time2 = $hours + $minets + $seconds;
    }
    
    $Time = $Time1 + $Time2; 
    $Seconds =  $Time%60;
    $Min = floor($Time/60);
    $Minuts = $Min%60;
    $Hourses = floor($Min/60);
    if ($Hourses<10){$Hourses='0'.$Hourses;}
    if ($Minuts<10){$Minuts='0'.$Minuts;}
    if ($Seconds<10){$Seconds='0'.$Seconds;}
    $result = $Hourses.':'.$Minuts.':'.$Seconds;
    return $result;    
}
      
		
	 
  }
?>
