I have a large amount of date rows that I'm migrating over from a legacy application to Drupal 7. My destination field is Date (ISO Format) with year, month and day selected. What format should this be in when I'm migrating it across?

I can see that it's stored as 2010-01-01T00:00:00 in the database so I'm using prepareRow() to manipulate the data like:

public function prepareRow($row) {
  // DOB not migrated correctly - old = serialised array
  //    watchdog('temp', print_r($row, TRUE));
  if ($row->profile_dob) {
    $dobarray = unserialize($row->profile_dob);
    watchdog('temp', print_r($dobarray, true));
    $row->profile_dob = date('Y-m-d\T00:00:00', mktime(0, 0, 0, $dobarray['month'], $dobarray['day'], $dobarray['year']));
    watchdog('temp', print_r($row->profile_dob, true));

This returns the expected format for the date however the data is not populated in the database. I've tried using 'c' as the date format as well with no luck.

  • 1
    You should really download and install migrate_extras, then take a look at Migrate Extras Date Example. It will help you a lot.
    – ermannob
    Jan 14, 2013 at 19:31
  • Have you enabled the date migration module under admin/modules?
    – user16858
    Jul 10, 2013 at 10:33

2 Answers 2


For date migration, you should use Migrate Extras module. Then you will be able to remove your code from prepareRow(), and just map the date field.

Migrate Extras will take care of reading you date and parse it.

In my migration I just had to set the timezone when I was importing birth dates.

Here's my mapping, as an example:

$this->addFieldMapping('field_birth_date', 'birthdate')->arguments(MigrateDateFieldHandler::arguments('Europe/Rome', 'Europe/Rome'));

I had similar issue and the issue got fixed when I updated the date module to the latest version which is "7.x-2.7". This doesn't have a separate date migration module and is merged with the date module.

I don't think Migrate Extras module is required for date migration. The link to Migrate Extras specifies that the date migration is built into the Date module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.