By fadihh on
Hi,
I am developing a module that needs to store some dates in the database. Here is a code snippet from one of the forms:
$form['start_date'] = array(
'#title' => t('Start Date'),
'#type' => 'date',
'#default_value' => '',
);
This is working fine but I have a problem in saving the value to the database (in the submit function of course). The database has a field name 'start_date' and it's type is 'datetime'. As I understood the value of the the date form element (in the submit function) is actually an array ( array['month'], array['year'], array['day] ).
So how can I convert the array to timestamp in order to save it in the database? ( I tried mktime but with no luck ).
Thank you very much.
Fadi
Comments
...
See http://drupal.org/node/227030#comment-750840
(The databse expects a 'yyyy-mm-dd' formatted string, not a timestamp.)
Thank you now I understand it better
Thank you now I understand it better