Simple question, but can't find it elsewhere:
How can I transform my string of time e.g. "09:30"
into in integer containing the total minutes in that time? (Solution for "09:30"
would be 570
)
I have tried a lot of stuff, including substr
, mktime
and strtottime
and just can't get it to work.
$time = explode(":","09:30");
$minutes = intval($time[0])*60 + intval($time[1]);
Just for reference, strtotime works as well and it may be a simpler solution.
$minutes = strtotime('09:30', 0) / 60;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With