date calculation

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
Hillu
Forum Newbie
Posts: 13
Joined: Sun Jun 15, 2008 11:06 am
Location: Addis Ababa

date calculation

Post by Hillu »

Hi, I have events which last for 3 months. The recent event starts on Dec 2008 and ends on Mar 2009. I have the starting date in a combo box how do I calculate the ending date? Thanks
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: date calculation

Post by pbs »

Can you please paste your combo box date values how you are using it.
Hillu
Forum Newbie
Posts: 13
Joined: Sun Jun 15, 2008 11:06 am
Location: Addis Ababa

Re: date calculation

Post by Hillu »

I have the following declarations in another file which I included in the file in question:
$currentdate = getdate();
$currentyear=$currentdate['year'];
$currentmon=$currentdate['mon']; // month in number
$currentday=$currentdate['mday'];

I also have a 'DateDropDown' function which lists dates by concatenating the year, months and date.
After the include statment I I wrote:
$DateSelected = sprintf("%04d-%02d-%02d", $currentyear, $currentmon, $currentday);

And finally the combo box.
<select class="button" name="cbo_starting_date" id="cbo_starting_date" >
<?php DateDropDown($DateSelected ,40,1,10); ?>
</select>

Thanks
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: date calculation

Post by pbs »

Try to use time() and mktime() functions, which will be easy.
Post Reply