Migration Source YML File import date string into date and time field of content type I have a json file full of data exported from a wordpress site, one field being a string representing a date and time: "03/15/2012 14:46:19".  I would like to import that string into a date and time field of a drupal 8 content type.

I am using a Migration from Source YML file.

fields:
 -
  name: date
  label: 'Date'
  selector: date


Then in process:

process:
  field_press_release_date: date        # is it as easy as this?


Is there a special plug in I'm not seeing listed on:
https://www.drupal.org/docs/8/api/migrate-api/migrate-process-plugins

I see format date, but couldn't get any format to work.  I have complete control over the format of the date string, I have to do some processing of data from wordpress before drupal so I can do pretty much whatever is needed, if it really is as easy as setting the date_field to the date_string from the fields list, what format does date_string need to be in?

I cannot find a simple example of importing a string into a date and time field, thank you for any assistance!
The migrate plugin that handles this is FormatDate.  It looks like you are missing the input and output date formats.  For date-only, you would do something like

process:
  field_date:
    plugin: format_date
    from_format: 'm/d/Y'
    to_format: 'Y-m-d'
    source: event_date


and for date+time, it would look something like

process:
  field_datetime:
    plugin: format_date
    from_format: 'm/d/Y H:i:s'
    to_format: 'Y-m-d\TH:i:s'
    source: event_time


When migrating into the core datetime/daterange fields, the to_format needs to be those strings (these were written to be generic, not just for those field types).  The from_format gets adjusted to your input source.  If you look at the references below, there is also a way to specify time zone.

That plugin is unit tested, so core doesn't provide any YAML example, but you may be able to glean samples from FormatDateTest.

References:


Added FormatDate migrate process plugin
https://www.drupal.org/project/drupal/issues/2820490
FormatDate migration process plugin now supports specifying of source and destination timezones
https://www.drupal.org/project/drupal/issues/2883892