# Date Help..!!!Urgent

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
Hello experts.

I am having a small problem with my hotel booking script ..

The hotels have a number of different seasons in each year each with a
different price per night, and i need to calculate how many days are
exists in the selected date range by user, and as per that the cost
will be set.

For eg. i've a season Demo Season, started from 1st Nov 08 to 31st
March 09 and the user selected the date i.e. 25th Oct 08 to 5 Nov 08.
(the dates which are not in any season, that calls as basic season)
(7 nights will fall in basic season and 4 nights will fall in Demo
season. Plz note, the user will check-out on 5th Nov, so that day will
not include in season)

but, i am unable to split the dates into correct form.

Any help/pointers would be appreciated

Many Thanks

Regards
Antonia.

## Re: Date Help..!!!Urgent

Message-ID:
max.fun101@gmail.com contained the following:

Sounds like a homework assignment...

First check out the date functions in the manual.

Then you need to think about the logic of what you are trying to do.
Assuming you have validated the user supplied data (you need a date
range in the future and should limit the length) then the range can lie
in several positions, entirely within a price band or overlapping.

By converting the price band date ranges to timestamps you will be able
to determine where the start date lies and the end date will tell you if
it overlaps or not.  If it overlaps it's just a two stage process,
adding the two values together at the end to give a final rate.
--
Geoff Berrow  0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk

## Re: Date Help..!!!Urgent

Hello Geoff

Let me give an example. ..
I've three main seasons,
Basic - For All (dates, which not in any season)
Season1 - 1st Sept, 08 to 31st Mar, 09
Seasion2 - 1st Jun, 09 to 30th Sept 09

Now, when i (user) selected the date from next year (lets assume from
Season1) then it is displaying the correct date.
But, when i selected the date 25th Aug 08 to 5th Sept 08
then it should return the following nights.
Basic : 7 nights and Season1: 4 nights
instead of this, i m getting the rates of Season2.

Plz help me .......

## Re: Date Help..!!!Urgent

Message-ID:
max.fun101@gmail.com contained the following:

--
Geoff Berrow  0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk

## Re: Date Help..!!!Urgent

The source wasn't necessary, it is a simple logic problem.

My first stab at it would be something like this:
- setup the season dates in your code/db as month/day (leave out the
year)
- append in the year based on the user input of their stay
- get the Julian values of the complete season dates and of the
visitor's requested period dates
- Then do simple comparative math to figure out the season day counts

Here is the php manual link to the function needed.

http://us2.php.net/manual/en/function.gregoriantojd.php

That should get you where you want.

good luck
Larry