MySQL TIMESTAMP columns
-
WP does not seem to use the MySQL SET TIME_ZONE command after connecting to the database – perhaps because the WP core tables do not contain any fields of type TIMESTAMP.
But this means that plugin developers who do use TIMESTAMP fields in their tables are potentially placing incorrect and non-portable values in those fields if they use the wpdb API to write to their tables.
My own plugin is an example: my blog is configured for EST but hosted in PST so the TIMESTAMP fields in my plugin’s tables do not truly contain UTC and, when I export those tables to another timezone, I get incorrect results.
So far as I can tell, my only solution is to create another instance of class wpdb with a new database connection, issue the MySQL SET TIME_ZONE command myself, and ensure my plugin always uses that special instance of wpdb.
Is it too much to ask that the core wpdb class use the MySQL SET TIME_ZONE command to set the connection’s time zone to be the same as the blog’s time zone? (as defined in General Settings)
- The topic ‘MySQL TIMESTAMP columns’ is closed to new replies.