There currently seems to be a bug when using PHP to make a dBase (.DBF) export file and using the DATE-type. Some fields, following the DATE-field, will be shifted a couple of positions to the right, and sometimes even emerge in the next record of the database.
This is the result you get when the following script is run (taken directly from the PHP.NET examples).
It will produce a database, which looks like this when opened in CDBF or DBF Manager.
Notice how in both examples the DATE-field isn’t properly displayed, because the database seems to be corrupted. Both programs show this (al though both show it differently), and any attempt to process the DBF file further will result in unexpected results.
**The solution?
** Create your DBF dBase file without the DATE-type, and replace it by a normal CHAR-type. After your export of the data was done, open the database with a tool such as DBF Manager, and convert the CHAR-type to a DATE-type manually (I agree, this sucks when you’re trying to automate certain tasks, because it requires manual input).
This is what the database looks like when replacing DATE with CHAR.
The example above was accomplished with the following code (where the “date”-column is now a “C”-type).
You can change the CHAR-field to DATE by going to the Structure Manager in DBF Manager (CTRL + S as a shortcut), and by changing the type.
After saving the database, it’ll be stored the way you would have expected it in the first place – with a correct DATE-type.
I’ve filed this as a bug report (#46282), and there seems to be a similar bug reported back in August 2007 (#42261) which also confirms unexpected results when using the DATA-type in a dBase environment, through PHP.