我正在尝试向使用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;
}
答案 0 :(得分: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;
}
答案 1 :(得分:2)
P.S。解决方案是:
'post_date' => $postdate = get_the_date( "Y-m-d H:i:s", $survey_id )