WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] post_date_gmt Reverts To Current Date (2 posts)

  1. WebTechGlobal
    Member
    Posted 4 years ago #

    I'm trying to use wp_update_post and apply the conditions that will schedule the post for future publish.

    This is a dump of my post object on the line before the update...
    ["post_date"]=> string(19) "2012-06-16 12:06:26" ["post_date_gmt"]=> string(19) "2012-06-16 12:06:26"

    The dates match and are in the future however the database only ever shows the current date in the post_date_gmt column. That doesnt make a whole lot of sense to me unless its something to do with revision records I'm just not sure.

    I think the trigger of the cause is the same as mentioned here...
    http://wordpress.org/support/topic/171725?replies=9

    My plugin will use wp_insert_post with minimum information, post_date_gmt for the revision is 0000-00 and so on. Now on writing this I just thought,what happens if I set the gmt date in my post object before wp_insert_post?

    I'll submit anyway and come back in a moment.
    Ryan

  2. WebTechGlobal
    Member
    Posted 4 years ago #

    Solution

    What I thought, if we don't apply...

    $my_post['post_date'] = date("Y-m-d h:m:s");
    $my_post['post_date_gmt'] = gmdate("Y-m-d h:m:s");

    To our post object when doing wp_insert_post the gmt date does not get set. Not sure if there is a good reason, I don't know enough but it looks more like something missing from the wp_insert_post function.

    Strange thing is why does the 000-00-00 and so on, effect an update that does have the post_date_gmt set? Obviously it is ignored if the prior record is empty forthis column.

    Again is there a good reason for that to happen?

Topic Closed

This topic has been closed to new replies.

About this Topic