MyBB Community Forums

Full Version: Less than 1 minute ago > % second(s) ago
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
1. Edit functions.php located in inc folder
2. Find

if($diff <= 60)
{
// Less than a minute
$relative['prefix'] = $lang->rel_less_than;
}

3. Replace it with

if($diff <= 60)
{
// seconds ago
    if($diff == 1) {
        return $diff . ' second ago';
    }
    return $diff . ' seconds ago';
}

[Image: GyVg8xX.png]
This doesn't work for me.
(2015-10-03, 08:18 PM)Ben C Wrote: [ -> ]This doesn't work for me.

That's weird. You sure you did it right?
Yep, throws up with a lot of fatal errors.
(2015-10-04, 10:17 AM)Ben C Wrote: [ -> ]Yep, throws up with a lot of fatal errors.

Mind showing me the errors? it's works just fine on my end.
Might be the ternary operators (though I don't know why). Try using this instead:

if($diff <= 60)
{
    // seconds ago
    if($diff == 1) {
        return $diff . ' second ago';
    }
    return $diff . ' seconds ago';
} 
(2015-10-04, 11:50 AM)Adamas Wrote: [ -> ]Might be the ternary operators (though I don't know why). Try using this instead:

if($diff <= 60)
{
    // seconds ago
    if($diff == 1) {
        return $diff . ' second ago';
    }
    return $diff . ' seconds ago';
} 

This works as well.
Now given: Parse error: syntax error, unexpected 'else' (T_ELSE) in /home/public_html/inc/functions.php on line 481
(2015-10-04, 03:33 PM)Ben C Wrote: [ -> ]Now given: Parse error: syntax error, unexpected 'else' (T_ELSE) in /home/thetechf/public_html/inc/functions.php on line 481

if($diff <= 60)
{
    // seconds ago
    if($diff == 1) {
        return $diff . ' second ago';
    }
   else {
    return $diff . ' seconds ago';
   }
} 

try that.
(2015-10-04, 05:17 PM)Sazze Wrote: [ -> ]
(2015-10-04, 03:33 PM)Ben C Wrote: [ -> ]Now given: Parse error: syntax error, unexpected 'else' (T_ELSE) in /home//public_html/inc/functions.php on line 481

if($diff <= 60)
{
    // seconds ago
    if($diff == 1) {
        return $diff . ' second ago';
    }
   else {
    return $diff . ' seconds ago';
   }
} 

try that.

https://gyazo.com/4c2cea235732be284c397f844f02e271
Pages: 1 2