I'm trying to format the date the user enters into the field to look like "'Y-m-d". The user is allowed to enter dates such as "013108" or "01312008" or "01/31/2008" or "01-31-2008" or "01-31-08". I thought strtotime would be able to translate all of these dates but it does not work most of the time. Is there something else I can use? Below is what i've been using with no success.
$value = date ('Y-m-d', strtotime($arr[1]));
You're going to have to parse them yourself (using strpos, substr, sscanf, or whatsyourfancy). BTW, does '111210' refer to November 12 2010, December 11, 2010, December 10, 2011, or January 2, 1970? (This is why strtotime is likely to have trouble)
I always find it so much less work in the long run to create 3 separate fields (year, month, day) and assemble them into the desired date format in my script rather than depending on the user to type it in a usable manner. Using <select> elements for each makes it even more reliable.