Support

Account

Forum Replies Created

  • Hi

    in addition to my previous post, here a clear video screenshots of what is going on:

    http://www.alankabout.com.au/date-and-time-picker.mp4

    as you can see, my desktop time was “19/09/2020 11.23 AM” where on the date & time picker it was “19/09/2020 1.23 AM”

    date & time picker is 10 hours behind my desktop (my current time in Sydney, Australia).

    hope the video helps

    thanks

  • Hi

    “With your original code was the default date time not set or was the default date time incorrect?”

    – we have lost the old original code

    —————————-

    for the second part of your reply, i don’t really know.
    the developer become blank and could not work out what to do next.

    let me clear something first:

    – server time and location are correct

    what is happen now is this:

    – when adding new post, date & time picker display wrong date & time (14 hours behind)

    – if i click on “NOW” it display the correct current date & time, but when i click on “publish”, date & time back wrong again (14 hours behind).

    all we needs is this:

    when adding new post, date & time picker is to display correct (our current) date & time without the needs of click on “NOW”, also to keep (our current) date & time after publishing the post.

    thanks

  • 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;
    }

  • thanks a lot John, works perfect.

  • Hi John

    thanks for the reply.

    so my code bellow how it will be after adding the codes you have in your reply?

    could you please reply with the full code as per you early reply.

    
    
    add_filter( 'parse_query', 'ba_admin_posts_filter' );
    add_action( 'restrict_manage_posts', 'ba_admin_posts_filter_restrict_manage_posts' );
    
    function ba_admin_posts_filter( $query )
    {
        global $pagenow;
        if ( is_admin() && $pagenow=='edit.php' && isset($_GET['ADMIN_FILTER_FIELD_NAME']) && $_GET['ADMIN_FILTER_FIELD_NAME'] != '') {
            $query->query_vars['meta_key'] = $_GET['ADMIN_FILTER_FIELD_NAME'];
        if (isset($_GET['ADMIN_FILTER_FIELD_VALUE']) && $_GET['ADMIN_FILTER_FIELD_VALUE'] != '')
            $query->query_vars['meta_value'] = $_GET['ADMIN_FILTER_FIELD_VALUE'];
        }
    }
    
    function ba_admin_posts_filter_restrict_manage_posts()
    {
        global $wpdb;
        $sql = 'SELECT DISTINCT meta_key FROM '.$wpdb->postmeta.' ORDER BY 1';
        $fields = $wpdb->get_results($sql, ARRAY_N);
    ?>
    <select name="ADMIN_FILTER_FIELD_NAME">
    <option value=""><?php _e('Filter By Custom Fields', 'baapf'); ?></option>
    <?php
        $current = isset($_GET['ADMIN_FILTER_FIELD_NAME'])? $_GET['ADMIN_FILTER_FIELD_NAME']:'';
        $current_v = isset($_GET['ADMIN_FILTER_FIELD_VALUE'])? $_GET['ADMIN_FILTER_FIELD_VALUE']:'';
        foreach ($fields as $field) {
            if (substr($field[0],0,1) != "_"){
            printf
                (
                    '<option value="%s"%s>%s</option>',
                    $field[0],
                    $field[0] == $current? ' selected="selected"':'',
                    $field[0]
                );
            }
        }
    ?>
    </select> <?php _e('Value:', 'baapf'); ?><input type="TEXT" name="ADMIN_FILTER_FIELD_VALUE" value="<?php echo $current_v; ?>" />
    <?php
    }
    
  • Hi

    thanks for the help, i did insert bellow but still no good:

    add_filter(‘acf/load_field/name=publishing_date’, ‘my_acf_default_date’);

    function my_acf_default_date($field) {

    $field[‘default_value’] = date(‘Ymd’);

    return $field;
    }

    it shows:
    September 15, 2019 12:00 am

    where it is on my desktop:

    September 16, 2019 03:20 am

    regards

Viewing 6 posts - 1 through 6 (of 6 total)