This PHP example is very easy. We mostly use the get current time function

date_default_timezone_set('Asia/Ho_Chi_Minh');

In this function, you can change any region which is suitable for your places. The whole source code for Calculate time

<?php
class TimeCountDown{
 public function calculateTime($time_to_calculate)
 {
  date_default_timezone_set('Asia/Ho_Chi_Minh');
  $time_now = intval(strtotime(date('H:i:s d-m-Y')));
  $temp_time = intval(strtotime($time_to_calculate));
  $distance_time = $time_now - $temp_time;
  if($distance_time < 0)
  {
   return "Time to calculate must less than now";
   exit();
  }

  if($distance_time == 1)
  {
   return "About a second ago";
  }
  else if(ceil($distance_time/60) == 1)
  {
   return "About a minute ago";
  }
  else if(ceil($distance_time/60) > 1 && ceil($distance_time/60) < 60)
  {
   return "About ".ceil($distance_time/60)." minutes ago";
  }
  else if(ceil($distance_time/(60*60)) == 1)
  {
   return "About an hour ago";
  }
  else if(ceil($distance_time/(60*60)) < 24)
  {
   return "About ".ceil($distance_time/(60*60))." hours ago";
  }
  else if(ceil($distance_time/(60*60*24)) == 1)
  {
   return "About a day ago";
  }
  else if(ceil($distance_time/(60*60*24)) < 7)
  {
   return "About ".ceil($distance_time/(60*60*24))." days ago";
  }
  else if(ceil($distance_time/(60*60*24*7)) == 1)
  {
   return "About a week ago";
  }
  else if(ceil($distance_time/(60*60*24*7)) < 4)
  {
   return "About ".ceil($distance_time/(60*60*24*7))." weeks ago";
  }
  else if(ceil($distance_time/(60*60*24*7*4)) == 1)
  {
   return "About a month ago";
  }
  else if(ceil($distance_time/(60*60*24*7*4)) < 12)
  {
   return "About ".ceil($distance_time/(60*60*24*7*4))." months ago";
  }
  else if(ceil($distance_time/(60*60*24*7*4*12)) == 1)
  {
   return "About a year ago";
  }
  else
  {
   return "About ".ceil($distance_time/(60*60*24*7*4*12))." years ago";
  }
 }
}

date_default_timezone_set('Asia/Ho_Chi_Minh');
echo date('H:i:s d-m-Y')."<br/>";

$time = new TimeCountDown();
$result = $time->calculateTime('10:07:11 21-12-2013');
echo "<div>".$result."</div>";
?>