• Resolved applecarrot

    (@applecarrot)


    Hello,

    we have a form with a hidden Date field (dd/mm/yyyy). Two independent customers submitted the form with a “Date submitted” on 26th April, but the hidden field shows the day before. For example, Date Submitted is “26 Apr 2022 @ 09:43 AM”, the hidden field is “25/04/2022”. Server time is UTC+2.
    Is this a bug? Unfortunately I have no idea how to reproduce it.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Laura – WPMU DEV Support

    (@wpmudev-support8)

    Hi @applecarrot

    I hope you’re well today!

    A “hidden date” in this case means that users cannot select the date themselves when submitting the form, right? It’s a field of type “hidden”, I suppose?

    I admit I didn’t encounter such issue so far but I can’t rule out anything yet. It would be helpful if you knew how to replicate this on purpose but if you don’t, we’d need to do some more testing.

    Would you mind sharing the form in question with us so we could test with this specific form?

    You can export the form from Forminator and then put export code on pastebin.com or export file on your Google Drive, Dropbox or similar account and post direct link to it in your response here.

    Let me know also what is exact date/time format set on your site (on “Settings -> Geenral” page, please.

    Best regards,
    Adam

    Thread Starter applecarrot

    (@applecarrot)

    Hello Adam,

    Thank you for your quick answer! I hope you are well too.

    Yes it is a field of type “hidden”. I still can’t replicate the error and it hasn’t happened again.

    Here is our form: https://pastebin.com/g1KsqU6S
    The date field is named ‘hidden-3’

    We have two mu-plugins, but they don’t change the date value: https://pastebin.com/LWNLVPjk https://pastebin.com/aDMRcnii

    Under Settings->General:

    Timezone = UTC+0
    Date format = F j, Y
    Time format = g:i a

    Regards,
    Marie-Christine

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @applecarrot

    Thank you for the update.

    It seems the issue is related to WordPress timezone,

    I checked the Forminator source code for the hidden field the code is:

    case 'date_mdy':
    $value = date_i18n( 'm/d/Y', forminator_local_timestamp(), true );
    break;
    case 'date_dmy':
    $value = date_i18n( 'd/m/Y', forminator_local_timestamp(), true );
    break;

    And the forminator_local_timestamp() that we use to get timestamp:

    function forminator_local_timestamp( $timestamp = null ) {
    // If no timestamp, get it current.
    if ( is_null( $timestamp ) ) {
        $timestamp = time();
    }
    
    return $timestamp + ( get_option( 'gmt_offset' ) * 3600 );
    }
    
    https://wordpress.stackexchange.com/questions/8400/how-to-get-wordpress-time-zone-setting

    You will see that we use the WordPress timezone option, I suggest set it to +2 to match your server timezone or the timezone from your location.

    Best Regards
    Patrick Freitas

    Thread Starter applecarrot

    (@applecarrot)

    Hello Patrick,

    Thank you for investigating!

    I switched the Website to Berlin time. But I’m not sure if it really is a timezone issue. The customers submitted the form at 05:39 AM and 09:43 AM (UTC probably?). Even with the time zone difference of 2 hours it’s the same day. Also, the dates of other customers that sent the form between 5 and 9 AM are correct.

    Could it be a caching problem? Maybe the customers visited the website the day before and the browser “remembered” the first date?

    Best regards,
    Marie-Christine

    Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @applecarrot !

    I’ve checked this further once more and I think it can actually be an issue caused by the caching.

    After importing the form, I’ve noticed that on the Behaviour tab the Load form using Ajax option was not enabled. Without that option, it’s possible that the page caching will cache the form’s HTML along with the data which is included in the Hidden field.

    It’s possible that the cache was cleared on the previous day and the data got “frozen” in place when someone visited the page with the form.

    Can you try enabling loading via Ajax and see if that helps?

    Warm regards,
    Pawel

    Thread Starter applecarrot

    (@applecarrot)

    Hello,

    you are right, Load form using Ajax was disabled. I noticed that the website is using a caching plugin, so I also activated “Prevent page caching on form pages”. There is no way to test if it works, so I’ll close this ticket for now and re-open it if it happens again.

    Thank you all a lot for your kind help!

    Best regards,
    Marie-Christine

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Hidden date field has different value than the submission date?’ is closed to new replies.