Forum Moderators: coopster
My problem is that I have no idea how to take a user-entered date, and make it something that mysql can then use.
Can anyone help me?
Thanks :)
What you want is to avoid people typing in stuff like "01/02/01", "March 32, 1994", or even "next weekend". PHP's date functions might be good, but they're not THAT good.
So... Make the user choose date parts from select boxes, instead of a text input.
A good example of that is here, for entering a Date of Birth. Try to enter a bogus date. You can't! It even figures out leap years.
h**p://www.seekwellness.com/askanurse/form.htm
Alternately, you can have a friendly popup calendar that allows the user to choose the date. Those are nice.
With either method, some javascript is handy to know. My favourite method is to keep a "hidden" field in your form, and use javascript to construct it into the YYYY-mm-dd format. When the form is submitted, use the value of that hidden field in your SQL queries.
A good date selector is an important part of a developer's arsenal. Sticky-note me off-list and I'll lend you a few scripts to do exactly what you want.