Jump to content
MakeWebGames

Recommended Posts

Posted
    function DateTime_Parse($time_stamp) {
	$time_difference = ($_SERVER['REQUEST_TIME']-$time_stamp);
$unit = array(
	'second',
	'minute',
	'hour',
	'day',
	'week',
	'month',
	'year'
);
$lengths = array(
	60,
	60,
	24,
	7,
	4.35,
	12
);
         for ( $i = 0; $time_difference >= $lengths[$i]; $i++ ) {
	$time_difference = $time_difference / $lengths[$i];
         }
	$time_difference = round($time_difference);
	$date = $time_difference . ' ' . $unit[$i]  . (($time_difference > 1 OR $time_difference < 1)?'s':'') . ' ago';
return $date;
   }

line 20...

Posted

fixed

 

 for ( $i = 0; $time_difference >= $lengths[$i]; $i++ ) {
	   $lengths[$i] = (array_key_exists($i, $lengths) ? $lengths[$i] : 1);
	$time_difference = $time_difference / $lengths[$i];
         }
	$time_difference = round($time_difference);
	$date = $time_difference . ' ' . $unit[$i]  . (($time_difference > 1 OR $time_difference < 1)?'s':'') . ' ago';

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...