Archive for the ‘Timing Function’ Category


function date_format($datetime){
$date_format = date(‘j F, Y’,strtotime($datetime));
return $date_format;
}

$datetime = ‘2013-07-15 12:07:58’;

echo date_format($datetime);

return 15 July, 2013 .

Advertisements

$datetime = “2013-07-08 07:07:32”;

$days = ‘5’;
$hours = ‘3’;

$new_datetime = date(‘Y-m-d H:i:s’, strtotime(“+$days days $hours hours”, strtotime($datetime)));

echo $new_datetime;

Timing Function

Posted: November 2, 2012 in All Category, Timing Function

<?php

$time = strtotime(‘2012-10-25 16:11:29’);

timingfunction($time).’ ago’;

function timingfunction ($time)
{

$time = time() – $time; // to get the time since that moment

       $tokens = array (
       31536000 => ‘year’,
       2592000 => ‘month’,
       604800 => ‘week’,
       86400 => ‘day’,
       3600 => ‘hour’,
       60 => ‘minute’,
       1 => ‘sec’
           );

          foreach ($tokens as $unit => $text) {
         if ($time < $unit) continue;
        $numberOfUnits = floor($time / $unit);
        return $numberOfUnits.’ ‘.$text.(($numberOfUnits>1)?’s’:”);
        }

}

?>

This Function return as like 1 sec ago, 1 mint ago, 1 hour ago, i week ago………………………