Created
June 27, 2018 16:12
-
-
Save aolin480/fb1b2baa6b3c96243ad269ba9ce576d6 to your computer and use it in GitHub Desktop.
Convert EPOCH timestamp to Wordpress post_date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$timestamp = '1517341140000'; | |
$post_arr = [ | |
'post_title' => 'Meh title', | |
'post_type' => 'post', //could be any custom post type | |
'post_content' => 'Meh body', | |
'post_category' => ['meh category'], | |
'post_status' => 'publish' | |
]; | |
$post_arr['post_date'] = date("Y-m-d H:i:s", substr($timestamp, 0, 10)); | |
// $post_id = wp_insert_post($post_arr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment