deepson2 Posted June 3, 2009 Share Posted June 3, 2009 Hello, I want to differentiate my 1 day and for more than 1 day it would be 2 day(s) or 3 day(s). now with this code its only getting output like 1 day(s) that i dont want. can anyone please help me. how can i get this $Dmin = 60 * 24; $Hmin = 60; $D = (int)($minutes_dif / $Dmin); $minutes_dif = $minutes_dif % $Dmin; $H = (int)($minutes_dif / $Hmin); $minutes_dif = $minutes_dif % $Hmin; else if($D > 0){ echo "$D day(s) "; } else if($D == $Dmin){ echo "$D day "; } else if($H > 0){ echo "$H hour(s) "; } else if($H == 1){ echo "$H hour "; } else if($minutes_dif > 0) echo "$minutes_dif minute(s) "; else if($minutes_diff <= 0) echo "About minute "; echo "ago"; thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/160773-solved-want-to-make-proper-condition-for-the-output/ Share on other sites More sharing options...
Adam Posted June 3, 2009 Share Posted June 3, 2009 You want to just change the order round slightly for part of your IF statement: else if($H == 1){ echo "$H hour "; } else if($H > 0){ echo "$H hours "; } Before, $H > 0 would always be matched before $H == 1 as obviously 1 is still more than 0. Quote Link to comment https://forums.phpfreaks.com/topic/160773-solved-want-to-make-proper-condition-for-the-output/#findComment-848496 Share on other sites More sharing options...
deepson2 Posted June 3, 2009 Author Share Posted June 3, 2009 Thanks a lot MrAdam. Its working!!!! Quote Link to comment https://forums.phpfreaks.com/topic/160773-solved-want-to-make-proper-condition-for-the-output/#findComment-848497 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.