I had a CCK date field that was configured to take a date input in the format "dd/mm/yyyy", e.g. 16/10/2010 for 16th Oct 2010. As a result, I set up my CSV input file to also use this input format.

However, when I imported my records, not all the date fields were imported and I discovered that on line 60 of mappers/date.inc, strtotime() is used which assumes date formats using the / separator are american style mm/dd/yyyy and those using - separators are dd-mm-yyyy.

The fix was simple for me, just change my input format to something a bit less ambiguous (yyyy-mm-dd). However, I wonder how this is dealt with for external feeds/sources? Perhaps a note could be added to the documentation at the very least?

Thanks for an awesome module btw!

Comments

imclean’s picture

We use hook_feeds_after_parse() to convert dates from an external feed.

/*
 * Implementation of hook_feeds_after_parse().
 */
function mymodule_feeds_after_parse(FeedsImporter $importer, FeedsSource $source) {
  if ($importer->id == 'my_feeds_importer') {
    foreach ($source->batch->items as $item_key => &$item) {
      list($d,$m,$y) = explode("/",$item['my date field']);
      $item['my date field'] = "$m/$d/$y";
    }
  }
}

However, it would be very handy to be able to configure the date format from within the Processor settings. Maybe it could use the Date API provided by the Date module.

dotman’s picture

in my csv, my dates are like this 2006-09-18, but after the import, their all set to today's date (or the date of import) like this 06/15/2011 - 20:06. How should I adjust my current published field so the the correct date is imported?

AniaMi’s picture

subscribe

Abelito’s picture

Use this format: "D, d M Y H:i:s O" (Thu, 29 Mar 2012 18:03:49 -0700)
Update: Use the Unix timestamp format: "U" (1333562099) Otherwise the timezone does not work.
http://us3.php.net/manual/en/function.date.php

I tried for hours to get it to work and finally!
Using: Feeds 6.x-1.0-beta11
and importing into the CCK field type "Datetime" using the Date module version 6.x-2.8
using a csv feed generated by another site.

Hope this helps someone else.

fprevos2’s picture

I'm having this problem but I'm use a RSS feed, I can't control the input. Why isn't this module using the CCK date format that I specify?

I look at the patch for #831470: Import fails due to dates not converted correctly but it doesn't look like it fix the right problem since it already commit to the version I'm using.

twistor’s picture

Issue summary: View changes
Status: Active » Closed (outdated)