Hi,
As I understood DragonFever, you don't have a problem changing your code (a bit). Here is my add value to it:
"in/function.php"
/**
* 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 >= 180){
$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) {
if($ordermleft >= 1){
$ordermleft = "$ordermleft";
} else {
$ordermleft = "";
}
if($ordermleft >= 1) {
$orderhleft = "$orderhleft {$lang->hour} {$lang->and} $ordermleft";
} else {
$orderhleft = "$orderhleft {$lang->hour} $ordermleft";
}
} else {
$orderhleft = "{$lang->more_then}$orderhleft {$lang->hours}";
}
if(!$ordermleft || $ordermleft == 1){ $ordermleft = "$ordermleft {$lang->minute}"; }
$actualtime = gmdate($mybb->settings['timeformat'], $last + ($offset * 3600));
if($orderhleft)
{
$result = "<abbr title=\"$actualtime\">$orderhleft {$lang->df_ago}</abbr>";
} else {
$result = "<abbr title=\"$actualtime\">$ordermleft {$lang->df_ago}</abbr>";
}
return $result;
} else {
return gmdate($mybb->settings['timeformat'], $last + ($offset * 3600));
}
}
you, also, need to add to
"global.lang.php" at the bottom:
$l['more_then'] = "more then";
If you'll notice, at the bottom of the resulted code I added that if the time is more then an 1 hour, minutes are added and when the time is more then 2 hours, I added "more then" to the front of the no. of hours.
Please note that you probably have to change the place of '$ordermleft'/'$orderhleft' and the before/after text as this was change by me to deal with a RTL language.
Hope this helps someone,
Ori...
I think my changed code has a delayed prompt in it. It seems that ittakes from 1 minute to 2 minutes, more then 1 minute. this is true for all the times (minutes full behind, hours+minutes do so as well).
If you see whats wrong, please correct (or this is normal?).
Ori...
OK. A third change in the code that solve a problem that caused the word 'minute' to appear twice when its in front of the word 'hour'. BTW, my code also has the line:
if(!$ordermleft || $ordermleft == 1){ $ordermleft = "$ordermleft {$lang->minute}"; }
in the hours calculation, so it says "Hour and Minute" and not "1 Hour and 1 Minute", as it should in Hebrew - I removed it from the code attached here.
I did change the code so that it should work in a LTR language (like English) based forum.
Ori...