Dealing with timestamps in WordPress is so fucking fucked.
While modifying a plugin to work correctly in WP 2.5, I came across this code snippet.
I haven’t had to deal with it myself, but maybe someone else will find it useful, or hilarious as I did. Here’s the code to make timestamps WordPress friendly (apprently):
// Dealing with timestamps in WordPress is so fucking fucked.
$offset = (int) get_option('gmt_offset') * 60 * 60;
$this->post['post_date'] = gmdate('Y-m-d H:i:s', $this->published() + $offset);
$this->post['post_modified'] = gmdate('Y-m-d H:i:s', $this->updated() + $offset);
$this->post['post_date_gmt'] = gmdate('Y-m-d H:i:s', $this->published());
$this->post['post_modified_gmt'] = gmdate('Y-m-d H:i:s', $this->updated());
| 2.9 |
Post Info
This entry was posted on Sunday, April 27th, 2008 and is filed under development. It has 98 viewsComments Feed. | Leave Comment | Leave Trackback.
Previous Post: Hey, get your HTML5 off my canvas »
Next Post: Put Ads on Top of Your Ads - Adbrite Ad Network »
Most viewed posts


























