IXR_date()仅显示当前日期

时间:2014-02-02 18:30:16

标签: api xml-rpc

我试图修复IXR_date()。我已经尝试过不使用strtotime而只是时间的stackoverflow问题。

$title = htmlentities($title,ENT_NOQUOTES,$encoding);
$keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
//$date = new IXR_Date( strtotime( '2015-12-25 09-20-58' ) );


//$pubdate = strtotime( '2015-04-08 13:46:43' ); 
//$pubdate = new IXR_Date( $pubdate );
$postdate = '2010-02-23 18:57:33 AM PDT';
//$postdate = '2010-02-23 18:57:33';
//$postdate = iso8601_to_datetime($postdate);
// $test = new IXR_Date($postdate);
$test = new IXR_Date( time($postdata)  ); 

$content = array(
    'title'=>$title,
    'description'=>$body,
    'post_status'=>'future',
    'dateCreated' => $test,
    'mt_allow_comments'=>0,  // 1 to allow comments
    'mt_allow_pings'=>0,  // 1 to allow trackbacks
    'post_type'=>'post',
    'mt_keywords'=>$keywords2,
    'categories'=>array($category),
    //'custom_fields' =>  array($customfields)


);

// this works like a charm
// Create the client object
$client = new IXR_Client($url);


 $params = array(0,$username,$password,$content); // Last parameter is 'true' which means post immideately, to save as draft set it as 'false'

// Run a query for PHP
if (!$client->query('metaWeblog.newPost', $params)) {
die('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage());
}
else
echo "Article Posted Successfully";
    var_dump($params);
    var_dump($test);

var_dumps显示的是当前日期,而不是我在2010-02-23 18:57:33 PDT中输入的日期。

var_dumps $ params

 3 => 
array (size=9)
  'title' => string 'test 134' (length=8)
  'description' => string 'ftw' (length=3)
  'post_status' => string 'future' (length=6)
  'dateCreated' => 
    object(IXR_Date)[301]
      public 'year' => string '2014' (length=4)
      public 'month' => string '02' (length=2)
      public 'day' => string '02' (length=2)
      public 'hour' => string '18' (length=2)
      public 'minute' => string '23' (length=2)
      public 'second' => string '27' (length=2)
      public 'timezone' => string '' (length=0)
  'mt_allow_comments' => int 0
  'mt_allow_pings' => int 0
  'post_type' => string 'post' (length=4)
  'mt_keywords' => string '' (length=0)
  'categories' => 
    array (size=1)
      0 => null

var_dump $ test

object(IXR_Date)[301]
  public 'year' => string '2014' (length=4)
  public 'month' => string '02' (length=2)
  public 'day' => string '02' (length=2)
  public 'hour' => string '18' (length=2)
  public 'minute' => string '23' (length=2)
  public 'second' => string '27' (length=2)
  public 'timezone' => string '' (length=0)

如何更改日期以便我可以安排将来的帖子

1 个答案:

答案 0 :(得分:0)

经过一番争吵,我发现这对我有用。虽然我不是100%肯定这是正确的,但它似乎正在输出我想要的东西。

$postdate = '20150223 18 57 33 CST';

$test = new IXR_date( $postdate);

我在此处找到的先前问题建议首先使用time()和字符串。或18:57:33.cst。然后使用

$content = array(
    'title'=>$title,
    'description'=>$body,

    'date_created_gmt' => $test,
    'mt_allow_comments'=>0,  // 1 to allow comments
    'mt_allow_pings'=>0,  // 1 to allow trackbacks
    'post_type'=>'post',
    'mt_keywords'=>$keywords2,
    'categories'=>array($category),
    //'custom_fields' =>  array($customfields)


);

那就是,如果您的xmlrpc查询是真的,也就是发布,请在将来安排发布。