Date Ranges

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
b00ker_b0y
Forum Newbie
Posts: 10
Joined: Thu Jun 22, 2006 7:16 am

Date Ranges

Post by b00ker_b0y »

Hi people;

Does anybody have an idea how to tackle this problem.

I will have a date range i.e. 17/07/2006 - 10/08/2006.

What I would like to be able to do it work out many days are in July from that range and how many are in August.

Anybody have any idea?

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

  1. Break the two dates apart into their components.
  2. use range() to create an array of the months to calculate on
  3. looping over the array from range(), use date() to pull how many days are in that month
  4. for the first month, subtract the day number from the components.
  5. for the last month, replace the number of days in the month with the day number from the components.
b00ker_b0y
Forum Newbie
Posts: 10
Joined: Thu Jun 22, 2006 7:16 am

Post by b00ker_b0y »

thank you; i will give that ago.

What do you mean my conponents tho?!

(new to all this)

Thanks again.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

day, month and year.
Post Reply