Apr 28

I recently migrated from Drupal to Wordpress on this site, and needed to migrate all of my old content to the new database. However, One of the problems with migrating the data from one content management system to another is dealing with the differences in database schema.

Drupal stores content timestamps as an int(11) field, which represents the number of seconds since epoch (midnight, January 1st 1970). Wordpress uses a datetime field. As the two formats are completely different, a conversion must take place. Drupal stores content in the node table, and the field that stores the content creation date is called created. We’ll need to select that field, and use the MySQL function FROM_UNIXTIME() to convert the date. Here’s how you do it:

mysql> SELECT title,type,FROM_UNIXTIME(created) as created,body FROM
> node ORDER BY created;

+-----------------------------------+--------+---------------------+
| title                             | type   | created             |
+-----------------------------------+--------+---------------------+
| Story1                            | story  | 2005-03-10 11:28:22 |
| Story2                            | story  | 2005-03-11 16:25:14 |
| A New Story                       | story  | 2005-03-11 16:31:18 |
+-----------------------------------+--------+---------------------+

The FROM_UNIXTIME() function also supports formatting of the result:

mysql> SELECT FROM_UNIXTIME(created, '%Y %D %M %h:%i:%s %x');
+--------------------------------------------------------------+
| FROM_UNIXTIME(created, '%Y %D %M %h:%i:%s %x') |
+--------------------------------------------------------------+
| 2005 10th March 11:05:32 2005                                |
+--------------------------------------------------------------+

To reverse the conversion, you would use the UNIX_TIMESTAMP() function to convert your datetime field to a Drupal-style int(11) timestamp.

tags: , , , , , ,

Apr 24

Hi everyone!

In case you haven’t noticed, things look a bit different around here. I am in the process of migrating the website content from a Drupal content management system to a Wordpress installation. This will allow me to emphasize the content provided here without having to work quite so hard on presentation issues.

Please be patient while I finish the migration, and check back often for updates!

tags: , , ,