0

hi i have a little bit of issue just thingking if somebody can give me a hand out here..

the issue is when i compute for a car rate..it will depend on the date of rental and the return date,which is already coverd the problem is it will not really just depend on the date but also in time of return

e.g

format(yyyy-mm-d)

startdate=2012-06-01

pickup hour=06:00

enddate=2012-06-02

return hour=06:00

rate:2500

but if the return date is already 5hour past than the pickup hour then rate=5000

e.g

startdate=2012-06-01

pickup hour=06:00

enddate=2012-06-02

return hour=11:00

rate:5000

here is the code in computing for the rate by day,week and month..but no idea how to compute the excess hour..

```
<?php
$vehicle;
date_default_timezone_set('Europe/London');
function rate($start_date, $end_date)
{
$interval = calculate_interval($start_date, $end_date);
// Total months
$months = floor($interval / DAYS_IN_MONTH);
$interval = $interval % DAYS_IN_MONTH;
// Total weeks
$weeks = floor($interval / DAYS_IN_WEEK);
$interval = $interval % DAYS_IN_WEEK;
// Total days
$days = $interval;
// Calculate total cost
return ($months * COST_PER_MONTH) + ($weeks * COST_PER_WEEK) + ($days * COST_PER_DAY);
}
/**
* Find total number of days passed between start and end dates inclusive.
*
* @param string $start_date
* @param string $end_date
* @return integer
*/
function calculate_interval($start_date, $end_date)
{
return floor((strtotime($end_date) - strtotime($start_date) + SECONDS_IN_DAY) / SECONDS_IN_DAY);
}
$start_date = '2012-06-01';
$pickuphour='06:00';
$end_date = '2012-06-02';
$returnhour='11:00';
if($vehicle=="Toyota VIOS 1.3 MT")
{
define('SECONDS_IN_DAY', 86400);
define('DAYS_IN_MONTH', 30);
define('DAYS_IN_WEEK', 7);
define('COST_PER_MONTH', 52500);
define('COST_PER_WEEK', 15000);
define('COST_PER_DAY', 2500);
}
if($vehicle=="Toyota VIOS 1300 E AT")
{
define('SECONDS_IN_DAY', 86400);
define('DAYS_IN_MONTH', 30);
define('DAYS_IN_WEEK', 7);
define('COST_PER_MONTH', 63000);
define('COST_PER_WEEK', 18000);
define('COST_PER_DAY', 3000);
}
if($vehicle=="Toyota VIOS 1500 G AT")
{
define('SECONDS_IN_DAY', 86400);
define('DAYS_IN_MONTH', 30);
define('DAYS_IN_WEEK', 7);
define('COST_PER_MONTH', 69300);
define('COST_PER_WEEK', 19800);
define('COST_PER_DAY', 3300);
}
if($vehicle=="Toyota ALTIS 1600 E MT")
{
define('SECONDS_IN_DAY', 86400);
define('DAYS_IN_MONTH', 30);
define('DAYS_IN_WEEK', 7);
define('COST_PER_MONTH', 73500);
define('COST_PER_WEEK', 21000);
define('COST_PER_DAY', 3500);
}
if($vehicle=="Toyota ALTIS 1600 G AT")
{
define('SECONDS_IN_DAY', 86400);
define('DAYS_IN_MONTH', 30);
define('DAYS_IN_WEEK', 7);
define('COST_PER_MONTH', 84000);
define('COST_PER_WEEK', 24000);
define('COST_PER_DAY', 4000);
}
if($vehicle=="Toyota INNOVA 2.0 J GAS MT")
{
define('SECONDS_IN_DAY', 86400);
define('DAYS_IN_MONTH', 30);
define('DAYS_IN_WEEK', 7);
define('COST_PER_MONTH', 84000);
define('COST_PER_WEEK', 24000);
define('COST_PER_DAY', 4000);
}
if($vehicle=="Toyota INNOVA J Dsl MT")
{
define('SECONDS_IN_DAY', 86400);
define('DAYS_IN_MONTH', 30);
define('DAYS_IN_WEEK', 7);
define('COST_PER_MONTH', 94500);
define('COST_PER_WEEK', 27000);
define('COST_PER_DAY', 4500);
}
$rate=rate($start_date, $end_date);
?>
```

*Edited
by ehpratah*