Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Following the already existing solution at https://www.drupal.org/node/2820490 , i have tried the FormatDate Plugin indicated but none of them seem to work for me when i try to migrate my date field from drupal 7 to drupal 8. Any idea what why
here is my code
langcode: en
status: true
dependencies: { }
id: remark
class: Drupal\migrate\Plugin\Migration
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: null
label: 'Student Article'
source:
plugin: d7_node
node_type: student_article_page
process:
type:
plugin: default_value
default_value: student_article
nid: tnid
vid: vid
langcode:
plugin: default_value
source: language
default_value: und
title: title
uid: node_uid
status: status
created: created
changed: changed
promote: promote
sticky: sticky
revision_uid: revision_uid
revision_log: log
revision_timestamp: timestamp
comment_node_student_article_page/0/status: comment
body:
plugin: get
source: body
field_student_article_date/value:
-
plugin: extract
source: field_article_date
index:
- '0'
- value
-
plugin: format_date
from_format: 'Y-m-d H:i:s'
to_format: 'Y-m-d\TH:i:s'
timezone: 'GMT'
destination:
plugin: 'entity:node'
migration_dependencies:
required:
- upgrade_d7_user
Can someone please tell me why the body field is able to migrate but the "field_student_article_date" is not able to migrate
Comments
Comment #2
docans CreditAttribution: docans commentedThis Solution worked for me for migrating a single Date field
Credit to http://data.agaric.com/migrating-date-field-content-drupal-8
Comment #3
cilefen CreditAttribution: cilefen at Institute for Advanced Study commentedThis is not critical.
Comment #4
osopolarHave you tried
field_student_article_date:
instead offield_student_article_date/value:
? In my example it works fine without/value
for a d6 to d8 migration. There are other examples with/value
, maybe the difference is that one is with and the other one without end date. Otherwise you may use xdebug to debug your migration and see what happens.Comment #5
docans CreditAttribution: docans commentedI tried every options possible from the previous ticket. I took away the
/value
and it didn't work for me. The solution i posted above is the only one that works in Drupal 8.4.2Comment #6
safetypinI'm experiencing the same issue.
The default migration moves all field data except for dates. In both drupal installs (d7 & d8), the fields are configured to only collect year/month/day without an end date.
Using the substr plugin from #2 worked.
Comment #7
safetypinI happened to look at my D8 database, and it looks like the date field data is actually being migrated, but for some reason the field data is not being displayed either on the node (Full display node) or in the node edit form.
Comment #8
docans CreditAttribution: docans commentedUse the solution at #2. It will work that way. The issue is in the date formatting
Comment #9
quietone CreditAttribution: quietone as a volunteer commentedtagging
Comment #10
heddnCan we reproduce this on 8.6 or 8.5? 8.4 is only getting critical bugs and security fixes at this point. Many folks have reported that d7 dates migrate just fine. We actually have automated tests that also say it works. Seems like a support request?
Comment #11
heddnIf this is reproducible at some point in the future, please re-open and add complete steps to reproduce.
Comment #12
Steve Tarnoski CreditAttribution: Steve Tarnoski commentedI went through lots of trial and error before this solution (migrating from Drupal 7 to 8.6):
In this case, we want the date field to remain empty if the source was also empty. We provide a default of 0, which allows this field to get skipped according to the next plugin.
Comment #13
GheorgheP CreditAttribution: GheorgheP as a volunteer commentedI changed the date format because the "DATE" field has the format that does not include H:i:s
Works for me:
TO
Comment #14
BrightBold@GheorgheP's formatting change in #13 solved the problem for me. Thanks!
Comment #15
paulsheldrake CreditAttribution: paulsheldrake at Kanopi Studios commentedThis config worked for me to get a D7 date field to go to D8 date field
Comment #16
juampynr CreditAttribution: juampynr at Lullabot for NBCUniversal commentedComment #17
jkstermitz CreditAttribution: jkstermitz commentedFollowing my D7->D8 migration (via the migrate UI) the date field in the D8 db is populated with data in the format: 2017-11-19T00:00:00 but the value is not displayed in node view, nor in edit view modes (date field appears blank). The D7 originating date field is populated in the db in the format: 2017-11-19 00:00:00
Can anyone tell me what the date format is "supposed" to be in the D8 db? In my case, I've only populated Y M D, with no time in the original D7 version, and I'd like to preserve that in the final.
Can anyone tell me if there might e something else in the d8 setup preventing the date from displaying, even though the data is available in the db?
Comment #18
rajveergangwar#2 worked for me.. Thanks
Comment #19
codeelegance CreditAttribution: codeelegance as a volunteer commentedFor anyone struggling with this AFTER a migration, this simple SQL query run in the database manager of your choice worked for me:
Field_dateline is the date field for my content type.
The problem seems to be the additional 'T00:00:00' in the field. Now, to be honest, my date field does not contain time parts, so YMMV.
Comment #20
thhafner CreditAttribution: thhafner commented#15 solved this issue for me.
Comment #21
ben.hamelin CreditAttribution: ben.hamelin at Oomph, Inc. commentedYep #15 for me too, specifically
to_format: 'Y-m-d\TH:i:s'
Comment #22
usmanjutt84#15 works for me too.
Comment #23
rpayanmIt works for me, too: