Copy link to clipboard
Copied
I apologize if this has been asked and I did not find it.
I'm using CS4 (php, mysql).
I have a form with a date field that is being inserted into a date field in mysql. I know mysql uses 2010-5-8 format which is fine. But I would like to be able to input the date 5/8/2010 or April 8, 2010 into my form and have it convert to the mysql format when i hit the submit button.
What code should i use, php or mysql to do the conversion? And where should the code go? Examples would be great!
It seems I have searched everyplace but have not found what I think I need.
Many Thanks in Advance
Greg
Copy link to clipboard
Copied
Hi there,
I use this code to insert the date in the MySQL format:
//I take the dd/mm/yyyy date and convert it into an array and then into 3 variables. After that I convert them to yyyy/mm/dd
list($day,$month,$year)=explode("/",$_POST['the_name_of_your_date_field']);
$date="$year/$month/$day";
Then your query should look like:
$query = "INSERT INTO your_DB.t_your_table (the_name_of_your_date_field) ".
"VALUES ('$date')";
Hope it helps
Copy link to clipboard
Copied
thanks. i'll give that a try tonight when i get home.
Thanks Greg.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now