Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $minutes = 153; // 153 == 5*30 + 3
- // How many x30 minutes fit in $minutes
- $whole = intdiv($minutes / 30); // For 153: intdiv(153, 30) == 5
- $remainder = $minutes % 30; // Always 0..29; For 153: 153 % 30 == 3
- $roundedMinutes = $whole * 30; // For 153: 5 * 30 == 150
- if ($remainder > 0) $roundedMinutes += 30; // For 153: += 30 == 180
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement