Hi. Thanks for the great work with feeds.
I've used feeds several times on Drupal 7, and it's a very useful module. I'm using the new Alpha 1 release for Drupal 8 the first time, but there appears to be a bug with importing time/dates. I've mapped a field to 'Authored on', and no matter which format I use, I get an error:
created.0.value: This value should be of the correct primitive type
I've tried Unix Timestamps, yyyy-mm-dd, Y-m-d h:i:s etc, but nothing seems to work. If I take out the created field and associated mapping, imports work fine.
I've spent hours trying a variety or formats, so I think there is a good chance this is a bug with Alpha 1?
Kind regards,
Comments
Comment #2
turpentyne commentedFollowing up on this, as I'd posted on the same problem, before realizing there was an issue already. I got one suggestion to use Epoch time (U), and that did work - but only after creating a whole new import. (though I did get an unrelated error, it appears: DOMDocument cannot parse XML").
When importing with anything but unix epoch time, I get this error on import attempt: "created.0.value: This value should be of the correct primitive type." Is there a way to provide those formats?
I'm currently using 8.x-3.0-alpha2. One step newer than original issue creator, but problem persists.
Comment #3
megachrizI think currently only Unix timestamp values are supported. Not dates in string format. It would be a good idea to add support for date strings as well.
The implementation is in \Drupal\feeds\Feeds\Target\Timestamp. I think the target should operate similar as \Drupal\feeds\Feeds\Target\DateTime.
Perhaps all we need to do is let Timestamp extend DateTime?
Comment #4
megachrizComment #5
achikas commentedI also need the post date to be imported.
I created a D7 views csv export with Unix Timestamp (U) as date format.
Feeds still can't import and says again:
created.0.value: This value should be of the correct primitive type.
Did anyone made a successful date field import, yet?
Comment #6
turpentyne commented@achikas ... I can't remember now, but I think a few weeks back, I just converted to Epoch time and imported that way. Don't quote me on that though. :)
Comment #7
achikas commentedI use Unix Timestamp for any date field now. I also works fine for date ranges.
For me its the best solution now, because i don't have to think about the different language date notations.
Comment #8
megachrizThis patch should you allow to import from a date string.
Let's see if I did not break the regular date target with it...
Comment #10
megachrizThis hopefully fixes the test failures and the coding standard issues.
Comment #11
megachrizMinor text correction.
Comment #12
bisonbleu commentedThanks for the patch @MegaChriz, that's great!
After applying the patch, I tried the following:
They all work except the last one. Makes sense to me since the logic of mm-dd-yyyy is at best ambiguous.
Here is the error.
Comment #13
megachriz@bisonbleu
Thanks for catching the SQL error! This patch should cause the validation to fail when providing a date like "08-14-2012".
Comment #15
megachrizCommitted #13.
Comment #16
megachrizActually this wasn't a bug. More like a feature request. Changing the issue category. This has effect on where this will be listed on the notes of the next release.
Comment #17
bisonbleu commentedHey @MegaChriz, so I took some time to test patch in #13 with the following.
"xx_id","xx_title","xx_author","xx_pubdate","xx_text"
1,"Title of article 01","admin","1532231185","This is the short body of article 01."
2,"Title of article 02","admin","1533231185","This is the short body of article 02."
3,"Title of article 03","admin","03/12/2012","This is the short body of article 03."
4,"Title of article 04","admin","03-12-2012","This is the short body of article 04."
5,"Title of article 05","admin","08-14-2012","This is the short body of article 05."
And got these messages after import. Is this what you would expect?
p.s. I'm not using the latest dev version. Should I?
Comment #19
back from 7 commentedI am having the same issue with getting the "authored on" date "post date" to work. What format should the date be in. Can someone provided some working examples. Also is this working on the dev version?
I am migrating thousands of nodes through feeds and need to sort by original date posted.
Comment #20
back from 7 commentedUsing the dev branch: 8.x-3.x-dev
I was able to get the following Date string to work with Feeds in my CSV file:
2019-05-12T15:47:13+0000
Comment #21
back from 7 commentedWhen compiling my csv from Views Data Export, I use a custom date format: "Y-m-d H:i:s"
This works!
Comment #22
maskedjellybeanI just wanted to say that I spent a long time trying to get a string in this format to import into a Date field:
9/15/2020 1:00 PM
The import would fail saying that the Date field value cannot be null. What ended up working was to install the feeds_tamper module and then applying the "String to Unix Timestamp".
Comment #23
lubwn commentedIs this still an issue? I am trying to import any date format to Created field on Articles node and it all fails. No matter if I try to import epoch timestamp or any other format, I am still getting an error. Applying patch from #13 did not work as well since the code is probably already in beta-1 release (newest one).
Comment #24
netzkombuese commentedI can confirm this is not working for the created and the changed field ( with this patch https://www.drupal.org/project/feeds/issues/3060308).
While this is working for my custom date fields, the core fields for created and changed can´t be set.
I export from views data export in the exact same format and use feeds tamper to do a string to timestamp.
For my custom date fields this is working.
For the created date I always get a
Drupal\tamper\Exception\TamperException: Input should be a string.Also without tamper plugin I can use any format (as said in #23) but without success.
Any ideas why this not working for created and changed mappings?
Thanks
Comment #25
iPat commentedI got this to work today, exporting the article "Authored On" dates from D7 to D9. Had to set the export date format to something readable (2022-04-18 13:16:40) and on the import source mapping, had to check both the "Raw value" and "Inner XML" options. And gloriously, it worked.
Comment #26
jweirather commented#21/#25 worked for me, custom format "Y-m-d H:i:s" to import date fields for feeds in Drupal 10 from a Drupal 7 site, in particular, to carry over "Post date" to "Created on", in order to preserve the post dates from migrated content. I did not need to use tamper.