Hi,
When programmatically creating a post, I am trying to set the post date, eg:
$my_post = array(
'post_title' => wp_strip_all_tags( $item_title ),
'post_content' => $post_content,
'post_status' => 'publish',
'post_author' => 1,
'post_date' => $postdate
);
wp_insert_post( $my_post );
And I am not able to set the post date programmatically.
If I hardcode the date, this does work:
$postdate = "2010-02-23 18:57:33";
But if I try to use a variable I cannot get it to work, even though both seem to contain exactly the same format and type:
echo of hardcoded $postdate:
2010-02-23 18:57:33 string
echo of $postdate if I get the date programmatically:
2021-02-06 13:07:03 string
Any help is very much appreciated.