Publish a Post on a Future Date Automtically

From digging through /wp-includes/post.php, it looks like you may need to do the following:

  1. set your post_status to future
  2. set the post_date to when you want it published
  3. insert the post as your code shows

Run the following code after inserting the post

$time = strtotime( $postdate . ' GMT' );
wp_schedule_single_event( $time, 'publish_future_post', array( $post_id ) );

That is what wordpress uses internally to schedule future posts. check the following function for more information

check_and_publish_future_post( $post_id )

error code: 523