Jump to content

Trouble With Conditional Statement


refiking

Recommended Posts

I am trying to use these conditional statements, but the error I keep getting is about a parse error.  Here is the relative snippet of code:

if(1 < $time < 40){
$ret = $time . ' seconds ago';
}
if(41 < $time < 60){
$ret = 'about a minute ago';
}
if(61 < $time < 120){
$ret = '1 minute ago';
}
if($time > 120){
$ret = round($time / 60). ' minutes ago';
}

Link to comment
https://forums.phpfreaks.com/topic/206003-trouble-with-conditional-statement/
Share on other sites

Removed exclusive conditions

 

UNTESTED:

 

if($time > 0 && $time <= 40) {
    $ret = $time . ' seconds ago';
} else if($time <= 60) {
    $ret = 'about a minute ago';
} else if($time <= 120){
    $ret = '1 minute ago';
} else {
    $ret = round($time / 60). ' minutes ago';
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.