WordPress, PHP, dateCreated

So back to my trying to post all my old blog entries. It’s important that they come over with the dates intact.

The MetaWeblogAPI uses a hashtable of RSS keys to describe the blog entry, so the obvious way to do it would be to have the pubDate RSS item as one of the keys, but that’s not how it works.

Instead, you have to supply a dateCreated, which they describe as an ISO.8601 date.

Read the description of an ISO 8601 date, and look at the examples. Now look at the PHP code that parses this date (from here):


1
2
3
4
5
6
7
$this->year = substr($iso, 0, 4);
$this->month = substr($iso, 4, 2);
$this->day = substr($iso, 6, 2);
$this->hour = substr($iso, 9, 2);
$this->minute = substr($iso, 12, 2);
$this->second = substr($iso, 15, 2);
$this->timezone = substr($iso, 17);

Not quite an ISO 8601 date parser is it? Turns out you have to specify the date in exactly the format it wants, which is:


1
20050905T12:00:00Z

So now I can control the date I post with. Another little hurdle crossed.