【问题标题】:Wondering what the default post date PHP string for Wordpress is?想知道 Wordpress 的默认发布日期 PHP 字符串是什么?
【发布时间】:2016-12-31 03:28:36
【问题描述】:

我正在尝试向使用 php 文件导出的 csv 添加一列。

post_date 的底部是我在提交/wordpress 帖子时需要知道正确字符串的部分。我目前在那里有一个默认日期请求,但这只是当前时间,而不是发布时间。您如何才能真正获得帖子的发布日期?非常感谢您的帮助!

$surveyArray = array(
      'id'                  => $survey_id,
      'title'               => $survey_title,
      'airline'             => $airlineName,
      'meal'                => $mealName,
      'test_great'          => $get_test_great[0],
      'fair_price'          => $get_fair_price[0],
      'friendly_host'       => $get_friendly_host[0],
      'right_temp'          => $get_right_temp[0],
      'looked_good'         => $get_looked_good[0],
      'would_reorder'       => $get_would_reorder[0],
      'comment'             => $get_comment[0],
      'airlane_race_number' => $get_airlane_race_number[0],
      'post_date'       => $postdate = date ("Y-m-d H:i:s"),
  );
  $allAirlinesAndAnswersInArray[] = $surveyArray;

}

【问题讨论】:

  • 检查this
  • 所以你想要 wordpress 帖子的创建日期?
  • 你能查一下thisthis
  • 是的,发布日期,而不是当前时间。我已经检查了这些链接,但不确定如何将它们集成到字符串中,因为当我将它们放入错误并说它必须是字符串时。感谢您的快速回复!真的很感激!

标签: php database string wordpress


【解决方案1】:

请在Wordpress.Stackexchange.com 打开与 WP 相关的主题

附言解决办法是:

'post_date'       => $postdate = get_the_date( "Y-m-d H:i:s", $survey_id )

【讨论】:

  • 非常感谢! :)
【解决方案2】:

请将此代码用于当前日期和时间,这是 wordpress 的默认日期时间

$blogtime = current_time( 'mysql' );

$surveyArray = array(
      'id'                  => $survey_id,
      'title'               => $survey_title,
      'airline'             => $airlineName,
      'meal'                => $mealName,
      'test_great'          => $get_test_great[0],
      'fair_price'          => $get_fair_price[0],
      'friendly_host'       => $get_friendly_host[0],
      'right_temp'          => $get_right_temp[0],
      'looked_good'         => $get_looked_good[0],
      'would_reorder'       => $get_would_reorder[0],
      'comment'             => $get_comment[0],
      'airlane_race_number' => $get_airlane_race_number[0],
      'post_date'       => $blogtime,
  );
  $allAirlinesAndAnswersInArray[] = $surveyArray;
}

【讨论】:

  • 感谢您的快速回复!我试过了,日期进去了,但每个帖子(当前时间)都是一样的。 2016-08-24 16:41:35 当我需要帖子添加日期/时间为什么会这样?
  • 10分钟后下班,明天回来!希望我们能解决这个问题。
猜你喜欢
  • 2013-03-31
  • 2019-02-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多