<?php
create function :
function get_timeago($ptime)
{
$estimate_time = time() - $ptime;
if( $estimate_time < 1 )
{
return 'just now';
}
$condition = array(
12 * 30 * 24 * 60 * 60 => 'year',
30 * 24 * 60 * 60 => 'month',
24 * 60 * 60 => 'day',
60 * 60 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach( $condition as $secs => $str )
{
$d = $estimate_time / $secs;
if( $d >= 1 )
{
$r = round( $d );
return 'about ' . $r . ' ' . $str . ( $r > 1 ? 's' : '' ) . ' ago';
}
}
}
use function
$timeago = get_timeago(strtotime($datee['date']));
?>
create function :
function get_timeago($ptime)
{
$estimate_time = time() - $ptime;
if( $estimate_time < 1 )
{
return 'just now';
}
$condition = array(
12 * 30 * 24 * 60 * 60 => 'year',
30 * 24 * 60 * 60 => 'month',
24 * 60 * 60 => 'day',
60 * 60 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach( $condition as $secs => $str )
{
$d = $estimate_time / $secs;
if( $d >= 1 )
{
$r = round( $d );
return 'about ' . $r . ' ' . $str . ( $r > 1 ? 's' : '' ) . ' ago';
}
}
}
use function
$timeago = get_timeago(strtotime($datee['date']));
?>
No comments:
Post a Comment