wordpressformsdate

Date Field Not Outputting Correct Format on URL


I'm building out a form on a hotel for room reservations. Currently, a user can select a check-in and checkout date. When the user selects a check-in or checkout date the format comes through in the URL as yyyy-mm-dd and in the URL as examplesite.com/1234?datein=yyyy-mm-dd. How can I get the date output to be formatted as mm/dd/yyyy?

Currently, this is my input tag:

<input class="date_in" id="datein" placeholder="" value="" type="date" name="datein">

Solution

  • Thank you @Ronak Hapailya and @mmm for your help. I figured out a different workaround because the output couldn't be modified in the format the travel software needed if the field remained a type="date" field.

    This is what I did. I changed the field to a type="text" and made the text field show a datepicker UI.

    The new code for the input fields:

    <input class="date_in" id="DateIn" value="mm/dd/yyyy" type="text" name="DateIn">
    
    <input class="date_out" id="DateOut" value="mm/dd/yyyy" type="text" name="DateOut">
    

    Jquery to make the text field appear as a datepicker field:

    jQuery(function($) {
      $('.date_in').each(function(){
        $(this).datepicker({ dateFormat: 'mm/dd/yy' }).val();
      });
      
      $('.date_out').each(function(){
        $(this).datepicker({ dateFormat: 'mm/dd/yy' }).val();
      });
    });