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());
This entry was posted in development and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by WP Hashcash

Subscribe without commenting