As I play about with MySQL and PHP, I'm interested in making a good "date picker," such as selecting the date 2010-11-11 (today's date).
In order to avoid making the user fill out dates manually in a form and then perform validation, I want to keep correct DATETIME values in my MySQL database and want a PHP page to offer rolling lists for the year, month, and day (for example, 2010-11-11).
My issue is: How can I make the simple rolling lists so that they can adjust dynamically if, for example, the user selects the date 2010-11-31 (which doesn't exist)? In other words, the user selects the year, the month, and then the day (which is dynamically altered to accommodate the actual number of days in the given month). I'm hoping that leap years will also be taken into account. When the user selects "Submit" after selecting all of them, the script will send the database a DATETIME value that is correctly structured (e.g. YYYY-MM-DD, or YYYYMMDD).
I believe the DATETIME type to be strict by default, which means the server will keep note of invalid dates that should be rather simple to error-check. But by doing what I just outlined, I wish to avoid this.