Home › Forums › General Issues › Use Date/Time picker as post publication date › Reply To: Use Date/Time picker as post publication date
I put this code in my functions file:
add_action('acf/save_post', 'test_update_post_date_from_acf', 20);
function test_update_post_date_from_acf($post_id) {
// remove this filter to prevent potential infinite loop
remove_filter('acf/save_post', 'test_update_post_date_from_acf', 20);
// date format must be "Y-m-d H:i:s"
$post_date = get_field('email_scheduled_date');
$post = wp_update_post(array(
'ID' => $post_id,
'post_date' => $post_date));
}
And I made sure that my datepicker return format is set to: Y-m-d H:i:s
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.