-1

Hello,

I am working on a website where you must be able to select a certain period in weeks (a week -> saturday - saturday), e.g. from 10 till 24 oktober which includes 2 weeks.
The only input for the php script is the year, month and day of both start and end date. So it sould compute the number of weeks.
Moreover it should be able to distinguish summer from the rest of the year. For example week 10 - 17 is summer and week 17 - 24 is not summer, then the script with inputs Start = 10 - 10 - 2009 and End = 24 - 10 - 2009 should return: Summerweeks = 1 and Nonsummerweeks = 1 and Totalweeks = 2.

I can't think of a better way then using a load of if and else statements boarding all exceptions, but this is a very unsecure code and also it is hard to renew for 2011, 2012 and so on.... The code must also work if the period consists of multiple months, or years. But the period 'normally' isn't larger then 5 to 6 weeks. So does anybody have an idea to help me ?

Thanks in advance.

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by digital-ether
0

Hello,

I am working on a website where you must be able to select a certain period in weeks (a week -> saturday - saturday), e.g. from 10 till 24 oktober which includes 2 weeks.
The only input for the php script is the year, month and day of both start and end date. So it sould compute the number of weeks.
Moreover it should be able to distinguish summer from the rest of the year. For example week 10 - 17 is summer and week 17 - 24 is not summer, then the script with inputs Start = 10 - 10 - 2009 and End = 24 - 10 - 2009 should return: Summerweeks = 1 and Nonsummerweeks = 1 and Totalweeks = 2.

I can't think of a better way then using a load of if and else statements boarding all exceptions, but this is a very unsecure code and also it is hard to renew for 2011, 2012 and so on.... The code must also work if the period consists of multiple months, or years. But the period 'normally' isn't larger then 5 to 6 weeks. So does anybody have an idea to help me ?

Thanks in advance.

Take a look at this class:
http://code.google.com/p/php-calendar-class/source/browse/trunk/calendar.class.php

The PHP datetime class would also be a starting point:
http://www.php.net/manual/en/class.datetime.php

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.