In a previous post I talked about learning more about the core of PHP, specifically the ArrayIterator class. I’ve been reading about it and I found a situation in which to apply what I’ve learned. I have a client that is using WordPress and a previous developer of theirs created a custom plugin, but didn’t always store the data in a consistent manner. At first I noticed it with dates, some were in the form of YYYY-MM-DD and others were in DD/MM/YYYY, and other places a Unix timestamp was used. I have my opinions about which one to use and why, but what really confused me was having them as different formats even in the same table. Instead of using a MySQL DATE, DATETIME, or TIMESTAMP field type, it is all intermixed.

However, the bright side of this situation: I have the possibility of slowly shifting some functionality out of their current CMS into a custom API that I will be building for my client. The reason this is a good thing in my view is that it allows me to import this data into a second database and normalize it as I go. Which is where the ArrayIterator will come in to play. I plan to use it with local copies of the code and database to see how effective it is as I parse the records and determine how the dates are stored and what to do with them. Maybe this isn’t the best use of it, but it is an opportunity to use it in a real world situation and apply what I’ve learned. Maybe I’ll find it isn’t the best tool for the job, or I may find that it helps keep things sane and it is worth the effort.