I need to pull out the post publish date in order to make the post post auto expire. The thing is I can't get the right publish date.
Here is my code:
global $wpdb;
$post_ids = $wpdb->get_results( "SELECT ID FROM $wpdb->posts WHERE post_status ='publish'" );
foreach($post_ids as $id){
$postdate = get_the_date("Y-m-d",$id ); //here is what I can figure out
.......
......etc
}
When I echo the $postdate, it come out with a wrong date. Not the date that exist in the wp_posts table.
How can I get the date properly?