Today I was trying to import articles from a custom php application. Post dates are stored as php date format 'Ymd', for example '20011223' for the 23rd of December, 2001. The database contains only dates, no time. I was doing this test with a small number of nodes, dating from end 2001 and early 2002.
Some settings and system details:
PHP 5.2.8
MySQL 5.0.58
Drupal 6.10
DateAPI 6.x-2.1
Node Import step 5: Timezone = Europe/Amsterdam | Date format = custom | Custom date format = Ymd
On step 7 of 8 (showing the first 10 nodes) everything looked OK except for the created date. Dates from 2001 showed up as "20/08/1970 - 15:40", while dates from 2002 resulted in "20/08/1970 - 18:08". A quick test with a unix timestamp converter (http://www.unixtimestamp.com/) suggests that the imported date is interpreted as a unix timestamp (with timezone conversion), instead of a Ymd formatted date.
For a second test I exported the same data to csv, but using SELECT TIMESTAMP(a.postdate, '%Y%m%d') instead of SELECT a.postdate in my SQL query, which generated dates like "2002-01-05 00:00:00". Combined with a custom date format 'Y-m-d H:i:s', this works perfect. In other words: My problem is solved, but I think I found a bug.
Comments
Comment #1
Robrecht Jacques commentedNode import first checks whether a date is in timestamp format (an integer) and only then the custom format. I have reversed this behaviour in CVS. Will be included in -rc5.
Thanks.
Comment #2
marcvangendWow! Thank you Robrecht for the quick response and for this fantastic module.