I have read through the documentation and it does appear that CCK Date fields are supported, but I'm not sure what syntax to use. A typical field is imported like this:

$this->addFieldMapping('field_foo', 'bar')
    ->description(t('Mapping bar in source to field_foo in destination'));

In my case, bar is a date value stored in a MySQL database table and field_foo is a Date field found in the content type that I'm importing to.

I understand that Date fields have a value and I need to map to that, but I have no idea what syntax to use. Any help would be much, much appreciated.

Thanks!

Comments

OliverMcc’s picture

looking for same, thanks

somanyfish’s picture

I wound up using this code for each of my date fields:

  public function prepare(stdClass $account, stdClass $row) { 
    $account->field_exam_date = _set_date_field($account->field_exam_date, $row->examdate);
    $account->field_sent_results_date = _set_date_field($account->field_sent_results_date, $row->sentresults);
    $account->field_sent_certificate_date = _set_date_field($account->field_sent_certificate_date, $row->sentcertificate);
  } 

function _set_date_field($date_field, $row_date) {
  //Don't set the date if it has the NULL value coming from the database 
  if ($row_date != '0000-00-00') {
    $date_field['und'][0]['value'] = $row_date . 'T05:00:00' ;
    return $date_field;
  }
}  

I'm not happy with it, but it works so I'm going with it for now.

mikeryan’s picture

Category: support » feature
Status: Active » Closed (duplicate)

Date support is indeed missing from the D7 branch, let's track that at #1021076: Support for date module in Drupal 7.