• Resolved jason9j

    (@jason9j)


    Hi – hope all is well. Would really love some help with something.

    I’m using Fluent Forms. On submit, I have it set to a URL redirect with a query string. I need one of the input options to be the submission date and time in a specific format. For example, March 20th, 2023 9:51:55am needs to render as 20230320095155. When I use the existing Fluent Forms smartcode in the URL for submission.created_at, it can only render it in one specific format, which is different to my needs. As a result, my link doesn’t work and I get a 404.

    How can I specify the date format for submission.created_at? Or alternatively, what can I paste into functions.php that can define the format required for submission.created_at as it appears in the URL query string? I was only able to find information about changing the time/date format for the date form field, which is not what I’m trying to change.

    Any help would be much appreciated – this has been driving me crazy!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Tahmid ul Karim

    (@tahmidulkarim)

    Hi @jason9j,

    There isn’t any direct option to change the format of the date provided by submission.created_at shortcode.

    You can modify the submission date format using the following filter hook – apply_filters(‘fluentform_filter_insert_data’, $response);

    You can follow our docs here on how to use the hook.

    Otherwise, you can also create your own custom SmartCode in Fluent Forms and fetch the submission date from the Fluent Forms database tables using custom codes. For more details on how to create custom SmartCodes, check our developer documentation here.

    Let us know if you have any other questions.

    Thank you!

    Thread Starter jason9j

    (@jason9j)

    Thanks for your reply. I’ve spent a few hours on this now and can’t seem to get it right. The submission date format in the redirect URL doesn’t change no matter what code I use. What follows below is an example, but I have tried many different variations of it. I have also used the own shortcode method, likewise trying many variations, but no shortcode ever became available for me to use, and typing it in directly didn’t change the format.

    function change_submission_date_format($submission_data) {
      $submission_data['submission_date'] = date('YmdHis', strtotime($submission_data['submission_date']));
      return $submission_data;
    }
    add_filter('fluentform_submission_data_before_insert', 'change_submission_date_format', 10, 1);

    I will save you from viewing all my coding attempts for both methods! Note that I am not really a coder, just trying to piece it together from the documentation, but all I need to do is specify date/time formats.

    Can you please let me know what is wrong with this code?

    Another issue is that for the general date picker inputs I have, for user friendliness the date format that the user works with needs to be different to the way that information parses in the redirect URL. For example, even though the URL itself needs the format 04/14/2023 to work, the datepicker needs to at least show it as 14/4/2023 (this is the way people read dates in my country), and even better would be Friday 14 April, 2023 to make it user friendly. Of course, the system needs to read a different format in the URL to display information.

    Finally, if there are two date pickers, can the second one’s selection ‘start’ from the selection of the first one, to save potential scrolling through months/years again?

    Thread Starter jason9j

    (@jason9j)

    Just an update – I was never able to figure out how to change the submission date format. Nothing I tried worked, and I couldn’t glean the answer from that documentation….

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to specify date and time format for submission.created_at in query string’ is closed to new replies.