In my Migration from Joomla to Drupal the format_date plugin failed.
created:
-
plugin: format_date
from_format: 'Y-m-d TH:i:s'
to_format: 'Y-m-d\TH:i:s'
source: created
With the error "Format date plugin could not transform '2012-02-26 11:25:38' using the format 'Y-m-d TH:i:s' for destination 'created'. Error: The date cannot be created from a format."
created:
-
plugin: format_date
from_format: 'Y-m-d TH:i:s'
to_format: 'Y-m-d\TH:i:s'
-
plugin: date_format_alter
source: created
If I add strtotime to in a date_format_alter process plugin it works.
class DateFormatAlter extends ProcessPluginBase {
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$unixTimestamp = strtotime($value);
return $unixTimestamp;
}
}
Comments
Comment #2
jeffwpetersen commentedComment #3
jeffwpetersen commentedComment #4
quietone commentedjeffwpetersen, glad you found a workaround.
I am sure the problem here is that the to format should either escape the 'T' character or not have it at all, it should be either
'Y-m-d\TH:i:s' or'Y-m-d H:i:s'.Can you provide a sample of the failing data to determine if my assumption above is correct?
Comment #5
jeffwpetersen commentedThe format in the joomla database is 2012-02-26 11:25:38 the table format is datetime.
Comment #6
quietone commentedThanks, that confirms what I was thinking in #4.
If the source data format is '2012-02-26 11:25:38' then the from_format should be `Y-m-d H:i:s` instead of 'Y-m-d TH:i:s', which is shown in the IS.
The plugin should be this:
@jeffwpetersen, can you test this change?
Comment #9
quietone commented@jeffwpetersen, has this been resolved?
More information about this issue was asked for in #6, 7 months ago.
Since we need more information to move forward with this issue, I am keeping the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Comment #10
benjifisher