0

Our Contact Form 7 form displays today's date on form load with this code:

[date today-date "Today"]

This gives us Today's date of 04/16/2022.

We would like to format the date to display date by month name.

For instance, April 16, 2022

Any ideas if this is possible?

Kenny
  • 1,058
  • 4
  • 20
  • 49
  • Read the docs https://contactform7.com/date-field/#:~:text=As%20previously%20explained%2C%20if%20a,date%20format%20keeps%20by%20default. – Grumpy Apr 16 '22 at 20:03
  • @Grumpy, first, thanks for your response. I should have stated in my initial post that I did try this but it does not work. It displays the code instead of the value it is intended to display. Am I using it incorrectly? Could you please shed some light? Here is what I tried. my form fieldname is curr_date ``[_format_curr-date "D, d M y"]` I also tried this (as a matter of guessing) ``[date _format_curr-date "D, d M y"]` – Kenny Apr 16 '22 at 23:56
  • @Kenny take a look on your form fieldname. Is curr-date or curr_date? It could be the problem. You may have to change the "-" for a "_" or maybe you have to change your form fieldname for a "-". – Èric Tramunt May 03 '22 at 15:09
  • @ÈricTramunt, thanks for the comment. That, unfortunately is not the problem. From everything I read and tried, that format can only work on Mail tab, not on the form itself. I tried it and it works on the Mail tab in that the user receives an email it shows the date in the format of day month name and two digit year. To make a 4 digit year, I had to make the y an upper case Y but the bottom line is that no solution yet on how to make that format work on CF7 form. – Kenny May 04 '22 at 16:57

1 Answers1

0

Short answer: no

Long answer: the format of the <input type="data" value="2022-04-16"/> field is set by the browser and not CF7, furthermore it cannot be custom formatted. There is a whole question/answers thread dedicated to this issue on stackoverflow.

The simplest way to solve this is to use a text input field instead and convert it to a date field using the the jQuery datapicker which has the advantage of being loaded from WP core.

  <script>
  $( function() {
    $( "#datepicker" ).datepicker("option", "dateFormat", "d M yy" );
  } );
  </script>
Aurovrata
  • 2,000
  • 27
  • 45