PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

change month in date to 3-letter abbreviation

  1. beedle

    The client is asking for the date format DD-MMM-YYYY. Of course three separate fields is not a solution.

    Looked at the previous thread below and I just can't believe that this can't be done. With other premium WordPress products that I pay for (themes, other plugins, etc), I see users get help with this minor degree of customization all the time.

    I understand it will break if I update, that's not a problem.

    Please either explain how to make this change (I am fine overwriting one of the existing date types if that makes it easier... the one with periods, for instance). Or at the very least, if I am forced to cobbled it together from three fields, please explain how to merge those into one field in the back end.


    Posted 11 years ago on Tuesday January 29, 2013 | Permalink
  2. The easiest solution is to use three fields and merge them into one with the gform_pre_submission filter. Create your form and add your three fields in the format you want. Use CSS to position them however you like.

    Add a hidden or admin only field (a single line text) and do not make it required. This is where the merged date field will be stored.

    add_action('gform_pre_submission_filter', 'concatenate_date');
    function concatenate_date($form) {
      // change input IDs here
      $dd   = $_POST['input_25'];
      $mmm  = $_POST['input_26'];
      $yyyy = $_POST['input_27'];
      // input_37 is the hidden field
      $_POST['input_37'] = $dd . '-' . $mmm . '-' . $yyyy;
      // return modified form object
      return $form;

    That would take fields 25, 26 and 27 and concatenate them with dashes in between, and store that in field 37.

    Posted 11 years ago on Wednesday January 30, 2013 | Permalink
  3. beedle

    Excellent. That seems straight-forward enough. I appreciate the code. I'll go give that a test.


    Posted 11 years ago on Wednesday January 30, 2013 | Permalink
  4. Let us know if you get stuck. We'll just need to know the field IDs of the three fields you want to string together, and the field ID where you want to store the value.

    Posted 11 years ago on Wednesday January 30, 2013 | Permalink