Gulshan Gulshan -4 years ago 98
PHP Question

Php mulltiply price with total hours

I have to multiple total no of hours (like 13:15) with price like(500).

Example:

$hours=13:15;
$price=500;
$result=$hours*$price;
$result=???


How can i multiple total no of hours with price to get final price??

Explain:
This question is not related to duplicated question tag. i have to multiple hours with price..and related question is converting hours into minutes.

Answer Source

Something like this:

<?php
    $hours='13:15';

    list($h, $m) = explode(':',$hours);  //Split up string into hours/minutes
    $decimal = $m/60;  //get minutes as decimal
    $hoursAsDecimal = $h+$decimal;


    $price=500;
    $result=$hoursAsDecimal*$price;

?>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download