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
fullfocus
Forum Commoner
Posts: 33
Joined: Fri Jun 30, 2006 2:51 pm

Date Calculation

Post by fullfocus »

Hello:

I was hoping someone can help me with a date calculation. I'm trying to calculate the number of days between a given date and the end of the month.

I have a form with three drop down boxes: month, day and year.

A user will submit a date using these drop down boxes. Based on their submission, I need to determine the number of days to the end of the month from the date which was submitted.

For example, if the person submits March 15, 2007 and the last day of the month of March is March 31, 2007. The number of days between the 15th and the last day of the month is 17.

How do I begin programming this calculation? Since the last day of the month differs from month to month (28th, 30th or 31st) I cannot figure out how to determine the last day of a given month.

Can someone help me out?

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

Post by feyd »

strtotime() and mktime() will probably be of interest here.
Post Reply