WordPress – Set post_date

I’m trying to set the post_date of a blog post to WordPress via XMLRPC.

I’m sending the data as a string:

Read More
$pubdate = '2010-04-08 13:46:43';

'post_date'=>$pubdate,

It appears 'post_date' is correct?

I also found this post losely related to the issue: http://wordpress.org/support/topic/330597

Can anyone suggest how I would post the date as: dateTime.iso8601

Related posts

Leave a Reply

2 comments

  1. To post the date as a <dateTime.iso8601> element (assuming you’re using the built-in XML-RPC client within WordPress, you want to cast your date as an IXR_Date object.

    // Convert the time to an integer value for parsing.
    $pubdate = strtotime( '2010-04-08 13:46:43' ); 
    
    // Convert the date to the right kind of object.
    $pubdate = new IXR_Date( $pubdate );
    

    Now, when you pass your array of arguments to make the request, passing 'pub_date' => $pubdate will create the correct XML element.

    See this other answer to a similar question for more information if you want a full, working example.