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.
I try to import csv file with different date formats:
2010-07-21
2010-07-21 20:23:12 +0000
2010-07-21 T 20:23 UTC
Wed Jul 21 20:23:12 2010
Wed, 21 Jul 2010 20:23:12 +0000
The result always is - Thu, 1970-01-01 00:00
Comment | File | Size | Author |
---|---|---|---|
#12 | 860942-12.patch | 1.62 KB | BrockBoland |
#11 | FeedsNodeProcessor_3.patch | 1.63 KB | gaele |
#8 | FeedsNodeProcessor.patch | 1.45 KB | Toxid |
Comments
Comment #1
alex_b CreditAttribution: alex_b commentedWhat do you map the date to? node published date? a CCK date field?
Comment #2
ANT0NI0 CreditAttribution: ANT0NI0 commentednode published date
Comment #3
alex_b CreditAttribution: alex_b commentedThanks for the update - that explains it. There is no date conversion on the node created/updated date mapping targets. We should use FeedsDateTime() for conversion if incoming date is not a UNIX timestamp in FeedsNodeProcessor::setTargetElement().
This is a feature request.
Comment #4
alex_b CreditAttribution: alex_b commentedFor the record, there are conversion problems with *some* dates, I have just requested that they be fixed on a level that benefits any date handling: #831470-13: Import fails due to dates not converted correctly.
Comment #5
alex_b CreditAttribution: alex_b commentedThis is implemented in Drupal 7 now.
These patches need to be backported to Drupal 6 for supporting conversion of dates mapped to created or updated.
http://github.com/lxbarth/Feeds/commit/d0b1283b50bef34ea7047bcb62cc9ac24...
+
http://github.com/lxbarth/Feeds/commit/c349d8131534bca44db3c58923e2e1479...
Comment #6
alex_b CreditAttribution: alex_b commentedComment #7
Toxid CreditAttribution: Toxid commentedI have no experience in backporting, but I believe I did it successfully since I get no errors on import. However, it did not solve the date problem, it becomes 1970-01-01 00:00.
Comment #8
Toxid CreditAttribution: Toxid commentedComment #9
wojtha CreditAttribution: wojtha commentedSubscribing
Comment #10
Toxid CreditAttribution: Toxid commentedThe problem for me was not feeds module, it was that the feeds_youtube plugin. Everything works fine for me now.
Comment #11
gaele CreditAttribution: gaele commentedcase 'body' was forgotten in #8.
Also $target_node->created instead of $value->created in second if clause (error in second patch from #5).
Comment #12
BrockBoland CreditAttribution: BrockBoland commentedHaving the same issue: the date field in the feed is in the format "Thu, 05 May 2011 17:31:38 UTC" and isn't being converted to a timestamp for the node created value.
I used the patch from #11 but found I had to tweak it a bit:
$value->getValue()
returns a FeedsDateTime object, but$node->created
needs to be set to a Unix timestamp. Since the FeedsDateTime class defines__toString
, I replaced it with this:$target_node->created = (string)$value;
Comment #13
japanitrat CreditAttribution: japanitrat commentedi dont know if this is directly related to this issue, but i tried #12 and it doesn't work on google-reader atom feeds where published-dates have the format "2011-05-21T13:01:52Z".
the imported nodes (from xml-file in atom format) have the current date, not the one from atom-feed.
[EDIT]
Ah, i just saw, that the default node-importer node-mapping has the published-source wrong ("published" whereas "Published date" is available in the dropdown only)
Comment #15
Jim Kirkpatrick CreditAttribution: Jim Kirkpatrick commentedIt's worth pointing out this is related to #1027020: ATOM parser not getting 'updated' date from Ning feeds as sometimes there's only an 'updated' field for dates in feeds, not the standard 'published' or 'issued'.
Comment #16
kpastore CreditAttribution: kpastore commentedFortunately, I was able to use the patch in #12 successfully to import the correct datetime for my nodes, even though it failed testing (comment #14).
Comment #17
twistor CreditAttribution: twistor as a volunteer commented