Search code examples
drupaldatedrupal-6drupal-fapi

Save date array to db


So, I have this element in my form:

<?php
$form['order']['date'] = array(
        '#type'          => 'date',
        '#title'         => 'Order date',
      );

In the form submit function I have got such array:

[values] => Array
    (
        [date] => Array
            (
                [year] => 2010
                [month] => 11
                [day] => 27
            )
    )

I am looking for a simple way to save this array in database and then I want to be able to extract this date from the database for that would be substituted back into the edit form.

Are there drupal api functions for this?


Solution

  • I think I found a simple way to do it, but it does not use Drupal api.

    $date = implode($form_state['values']['date']); // $date = 20101127;