/**
* Calculates how many minutes past since the given time.
*
* @param int The unix timestamp of the given time
* @return string The formatted time
*/
function timeAgo($last)
{
global $mybb, $mybbadmin, $lang;
$timenow = TIME_NOW;
$diff = $timenow - $last;
if(!$offset && $offset != '0')
{
if($mybb->user['uid'] != 0 && array_key_exists("timezone", $mybb->user))
{
$offset = $mybb->user['timezone'];
$dstcorrection = $mybb->user['dst'];
}
elseif(defined("IN_ADMINCP"))
{
$offset = $mybbadmin['timezone'];
$dstcorrection = $mybbadmin['dst'];
}
else
{
$offset = $mybb->settings['timezoneoffset'];
$dstcorrection = $mybb->settings['dstcorrection'];
}
// If DST correction is enabled, add an additional hour to the timezone.
if($dstcorrection == 1)
{
++$offset;
if(my_substr($offset, 0, 1) != "-")
{
$offset = "+".$offset;
}
}
}
if($offset == "-")
{
$offset = 0;
}
if($last < $timenow && $diff <= 46200)
{
$order = $timenow - $last;
while($order >= 60){
$order = $order-60;
$ordermleft++;
}
while($ordermleft >= 60){
$ordermleft = $ordermleft-60;
$orderhleft++;
}
if($ordermleft == 0){
$ordermleft = "";
} else {
$ordermleft = "$ordermleft {$lang->minutes}";
}
if($orderhleft == 0){
$orderhleft = "";
} elseif($orderhleft == 1) {
$orderhleft = "$orderhleft {$lang->hour}";
} else {
$orderhleft = "$orderhleft {$lang->hours}";
}
if(!$ordermleft || $ordermleft == 1){ $ordermleft = "1 {$lang->minute}"; }
$actualtime = gmdate($mybb->settings['timeformat'], $last + ($offset * 3600));
if($orderhleft)
{
$result = "{$lang->df_ago} <abbr title=\"$actualtime\">$orderhleft</abbr>";
} else {
$result = "{$lang->df_ago} <abbr title=\"$actualtime\">$ordermleft</abbr>";
}
return $result;
} else {
return gmdate($mybb->settings['timeformat'], $last + ($offset * 3600));
}
}
$lastpost_date = my_date($mybb->settings['dateformat'], $lastpost_data['lastpost']);
$lastpost_time = my_date($mybb->settings['timeformat'], $lastpost_data['lastpost']);
$lastpost_time = timeAgo($lastpost_data['lastpost']);
if(ereg($lang->minute, $lastpost_time) || ereg($lang->hour, $lastpost_time))
{
$lastpost_date = "";
}
else
{
$lastpost_date = my_date($mybb->settings['dateformat'], $lastpost_data['lastpost']);
}
$lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
$lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
$lastposttime = timeAgo($thread['lastpost']);
if(ereg($lang->minute, $lastposttime) || ereg($lang->hour, $lastposttime))
{
$lastpostdate = "";
}
else
{
$lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
}
$l['df_ago'] = "Hace";
(15 Jan, 2010, 4:28 pm)vmaster17 escribió: podrias especificar mas detalladamente dicho tutorial porque se me hace dificil aplicar dichos pasos ya que he probado algunas veces haciendo lo que vos decis y sin exito!
Salu2s!