refiking Posted June 27, 2010 Share Posted June 27, 2010 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 More sharing options...
mattal999 Posted June 27, 2010 Share Posted June 27, 2010 UNTESTED: if($time < 40) { $ret = $time . ' seconds ago'; } else if($time < 60) { $ret = 'about a minute ago'; } else if($time < 120){ $ret = '1 minute ago'; } else if($time > 120) { $ret = round($time / 60). ' minutes ago'; } Link to comment https://forums.phpfreaks.com/topic/206003-trouble-with-conditional-statement/#findComment-1077954 Share on other sites More sharing options...
Mchl Posted June 27, 2010 Share Posted June 27, 2010 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'; } Link to comment https://forums.phpfreaks.com/topic/206003-trouble-with-conditional-statement/#findComment-1077956 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.