Migrations with Time Field

Created on 15 May 2020, over 4 years ago
Updated 7 July 2023, over 1 year ago

How does one migrate time data into Time Field range? For instance, given the following fieldname of (field_start_end_time), this attempts to follow Time Field's subfield schema in a simple migration, but fails:

...
  field_start_end_time/from:
    plugin: format_date
    source: startDate (used for this example only)
    from_format: 'Y-m-d\TH:i:s\Z'
    to_format: 'h:i a'
    from_timezone: 'America/New_York'
    to_timezone: 'America/New_York'

  field_start_end_time/to:
    plugin: format_date
    source: endDate (used for this example only)
    from_format: 'Y-m-d\TH:i:s\Z'
    to_format: 'h:i a'
    from_timezone: 'America/New_York'
    to_timezone: 'America/New_York'
...
πŸ’¬ Support request
Status

Needs review

Version

1.1

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States ptgraber Raleigh, NC

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¬πŸ‡§United Kingdom natts London

    Just to add to this, for me, I was just migrating into a simple time field, not a time range, from an external MySQL table via CSV.

    So I was able to output the time field in my SELECT query using MySQL's TIME_TO_SEC() function (which outputs an integer between 0 and 86399, representing the seconds from midnight), and then my migration YAML just needed to be:

    ...
    source:
    ...
      fields:
        - name: time
        - label: 'Time'
    ...
    process:
      field_time/value: time
    ...
    
  • πŸ‡ΊπŸ‡ΈUnited States todea

    Just an fyi, I used the following to move from the timefield module to time_field.

    ...
    source:
      plugin: d7_node_complete
      node_type: page
    ...
    process:
      field_hours_monday:
        -
          plugin: sub_process
          source: field_hours_monday
          process:
            from: value
            to: value2
    ...
    
Production build 0.71.5 2024