[RESOLVED] Insert Date in Table using FORM
HI, I work with DW CS6 and MySQL...
I have created a form to insert records in a table... I introduce a date in a textBox and when I insert the record in the database table, the field date appears this way: 0000-00-00
I have tried to write the date in the form in diferent masks but always in the table of database was inserted 0000-00-00
Somebody could help me?
Dates are stored in the format yyyy-mm-dd in MySQL but can be displayed as in many ways using date_format.
SELECT DATE_FORMAT(date, %M %e, %Y) AS mydate FROM mytable
date would be something like 2012-12-02
and mydate would be December 2, 2012
Dasher, thanks for help...
I didn't know that format must be YYYY-MM-DD
I have tried to insert record with this type of date and it works perfectly. Thanks you very much. Now, I need to convert "spanish date"-> "31/12/1999" to "1999-12-31"... i will try to make a function.
for converting try looking at the DateTime class or strtotime with date. An example using DateTime might look like:
$date = '31/12/1999'; // or however you want to get it set
$date = DateTime::createFromFormat('m/d/Y', $date);
$date = $date->format('Y-d-m');
echo $date; //see the results
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)