Home › Forums › Backend Issues (wp-admin) › date & time picker "NOW" issue › Reply To: date & time picker "NOW" issue
Hi John
it is being a long time since your last reply
we have tried a different date and time picker but unfortunately it did not works as it should.
now back to ACF date & time picker.
we have installed the bellow code but again, we still having a problem with current time.
example:
we create a post at :19/09/2020 12:49 am
but on the date & time picker it is: 18/09/2020 2:49 pm
even so, the developer is completely lost and can not figure out what to do no more.
any help would be much appreciated.
the code:
add_action( ‘acf/save_post’, ‘set_submit_time’ );
function set_submit_time($post_id) {
update_field(‘entry_post_date’, date(‘Y-m-d H:i:s’), $post_id);
}
add_action(‘save_post’, ‘change_content’);
global $post;
global $wpdb;
function change_content($post_id) {
$datefield = get_post_meta($post_id,’entry_post_date’,true);
$post_date = date(“Y-m-d H:i:s”, strtotime($datefield));
$my_post = array();
$my_post[‘ID’] = $post_id;
$my_post[‘post_date’] = $post_date;
remove_action(‘save_post’, ‘change_content’);
wp_update_post( $my_post );
add_action(‘save_post’, ‘change_content’);
}
add_filter(‘acf/load_field/name=entry_post_date’, ‘my_acf_default_date’);
function my_acf_default_date($field) {
$field[‘default_value’] = date(‘Y-m-d H:i:s’);
return $field;
}
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.