Hi,

i´m having trouble to get the birthay, by the format dd/mm/yyyy from a input field form and then insert into a MySQL database. The MySQL column type is date, and as i´m working with the string from the HTML form, it´s not saving this information at the database.

I have take a look at strtotime function, but it is still not working. Someone can help me to handle this?

The basic rule is: get one string like 30/08/2002 via post form and convert it from his string type to a date one, in reason to save it at MySQL.

Thanks

    MySQL stores the temporal data type DATE in a 'YYYY-MM-DD' format. I'd suggest making your data input form using three input fields (with select drop-downs for the month and day components, and a text area for the year component), and doing some quick validation on the user-supplied data to prevent users from entering a birthday of February 29, 1903:

    // Suppose we have three form entry fields named day, month and year.
    // run the checkdate function to assure the date entered *is* valid:
    if(checkdate($_POST['month'], $_POST['day'], $_POST['year'])) {
    	// Make a MySQL-friendly date string:
    	$mysqldate = $_POST['year'] . '-' . $_POST['month'] . '-' . $_POST['day'];
    } else {
    	echo "The date you entered doesn't exist.";
    }
    
      Write a Reply...