• Hi @takayukister ,

    Apparently, the CF7 plugin possible is using a wrong date, which is the one presented on a specific form details and that is different than the one presented on the server. Seems like CF7 has a failure in retrieving date_default_timezone_set as set one “wp-settings.php”.

    One can see this from an error on a “Contact Form Submissions“ plugin using two clocks.. One of the submission which is wrong, and the second from the server.
    https://wordpress.org/plugins/contact-form-submissions/

    While the date on the forms’ submissions table is correct and uses the offset for region as defined on server, the specific date on a specific form submission report shown a date at default UTC time without the offset.

    Possibly there is a usage of two different $dates on contact-form-submissions / Admin.php file.

    On line 336 there is a usage of: ” $date = date_i18n($datef, strtotime($post->post_date)); ?>”

    /**
    * Output for the actions metabox
    */
    public function actions_meta_box($post)
    {
    $datef = __(‘M j, Y @ H:i’);
    $date = date_i18n($datef, strtotime($post->post_date)); ?>
    <div id=”minor-publishing”>

    <div id=”misc-publishing-actions”>
    <div class=”misc-pub-section curtime misc-pub-curtime”>
    <span id=”timestamp”><?php _e(‘Submitted’, ‘contact-form-submissions’); ?> : <b><?php echo $date; ?></b></span>
    </div>
    </div>
    <div class=”clear”></div>
    </div>
    <?php

    }

    While on Line 356 usage of “wpcf7s_posted_values”

    /**
    * Get the posted data for a form
    *
    * @param integer $post_id the form post ID
    *
    * @return array the form values
    */
    public function get_mail_posted_fields($post_id = 0)
    {
    $posted = array();
    $post_meta = get_post_meta($post_id);
    $posted = array_intersect_key(
    $post_meta,
    array_flip(array_filter(array_keys($post_meta), function ($key) {
    return preg_match(‘/^wpcf7s_posted-/’, $key);
    }))
    );

    $posted = apply_filters(‘wpcf7s_posted_values’, $posted);

    return $posted;
    }

    Regards, Ehud

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter ziegel

    (@ziegel)

    Hi,

    Error seems not on CF7 but on the submission plugin.

    Any other thoughts?

    Thread Starter ziegel

    (@ziegel)

    Hi @takayukister ,

    I found a temporary fix for the submission plugin, which involves manually manipulating $post->post_date there.

    This is strange. Although [_time] and [_date] on CF7 itself are correct, possibly on a lower level of the data, the time stamp with the time zone adjustment from server is not taken, and time is UTC…

    I’m saying this as I do not see where from the submission plugin takes its date and time data.. but the CF7 itself.

    My fix on the admin.php file of the submission plugin is:

    public function actions_meta_box($post)
    {
    $datef = __(‘M j, Y @ H:i’);
    $date = date_i18n($datef, strtotime( ‘$post->post_date’ . ‘+3’ )); ?>

    where instead of strtotime($post->post_date) I wrote:
    strtotime( ‘$post->post_date’ . ‘+3’ )

    Can you please check if any where on CF7 the date is held as data before the adjusment for time zone recieved from the server according to :
    date_default_timezone_set( ‘Location’ );

    Thread Starter ziegel

    (@ziegel)

    BTW

    Replacing to:
    get_the_date(‘Y-m-d H:i:s’, $post_id)

    also brought the wrong date before the time zone adjustment.

    Is there a special VAR in CF7 that holds the date after time zone adjustment?

    Thread Starter ziegel

    (@ziegel)

    Ok..

    This fixed it for the specific need:
    $date = date_i18n($datef, strtotime($post->_date)); ?>

    HOWEVER
    I think additional places on my code (mPDF PDF generation?) are fetching wrong time, before time zone adjustment, from the CF7 plugin generated data.

    Can you please check, is that so?
    And, if so, can you fix the data stored at the lowest data level, for the date and time?

    Thread Starter ziegel

    (@ziegel)

    Note
    The problem seems to be in “$post->post_date” of CF7, where this data should have been reflecting the PHP time zone adjustment as set in wp-settings.php using “date_default_timezone_set( ‘Location’ );”, while it is using UTC time-zone as default without the required adjustment.

    Thread Starter ziegel

    (@ziegel)

    Is it issue originate from

    wp-includes/post.php where $time is set as:
    $time = strtotime( $post->post_date_gmt . ‘ GMT’ );

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Please check Welcome to Support Forum — Please Read Before Posting before you post next time.

    Thread Starter ziegel

    (@ziegel)

    Hi @takayukister ,

    Thanks. Duplicate is my mistake, as I mistakenly posted twice thinking the second time is the submission plugin support page.

    However, issue still requires addressing. Seems like CF7 holds a variable with the wrong $date which is fetched by other plugins and causes error. Is that so, or it’s done by design to hold UTC and adjusted dates, so both would be accessible?

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘CF7 Specific Form Submission Report uses wrong $date time’ is closed to new replies.