My problem is calculation for accomodation.
I've got x periods of year
01/01 - 28/05
29/05 - 02/07
03/07 - 03/09
04/09 - 01/10
02/10 - 31/12
Each period of year has his price for accomodation
for example:
01/01 - 28/05 35€
29/05 - 02/07 45€
03/07 - 03/09 55€
04/09 - 01/10 45€
02/10 - 31/12 35€
Here comes problem
If user wants to spend his vacation on period from 28.06 until 07.07 here come two prices.
Calculation should be: 2 days at price 45€ and 7 day on price 55€
Total of this should be 445€.
periods are in database in timestamp format
if somebody can point me in right direction
regards ddragas
calculation for accomodation
Moderator: General Moderators
Off the top of my head, if someone's period of vacation is stored in db as timestamp, I would sugest using
http://www.php.net/date
then you can get the month / day of start / end and do a function that takes $month and $day and returns the price. That function can have a buncha if/elseifs or a switch statement.
This is a bit of a hack for a solution but it would work, I'm pretty sure theres more efficient solutions to this tho.
http://www.php.net/date
then you can get the month / day of start / end and do a function that takes $month and $day and returns the price. That function can have a buncha if/elseifs or a switch statement.
This is a bit of a hack for a solution but it would work, I'm pretty sure theres more efficient solutions to this tho.