How can draft post after 1 year

Try this code (maybe working) , but i’am not sure cause not testing :

function amin_show_expire(){
  global $wpdb;
  $result = $wpdb->get_results("SELECT * FROM wp_posts WHERE post_type="CUSTOM" AND post_status="publish"");
  if( !empty($result)) foreach ($result as $a){
      $show_time = get_the_time("Y-m-d", $a->ID );
      $show_time=date("Y-m-d", strtotime("+1 years", strtotime($show_time)));
      if ( $show_time < date("Y-m-d")){//compare 1 year after post with current time
          $my_post = array();
          $my_post['ID'] = $a->ID;
          $my_post['post_status'] = 'draft';
          wp_update_post( $my_post );
      }
  } // end foreach
}

add_action( 'init', 'amin_show_expire' );

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş