How to set input type date in dd-mm-yyyy format using HTML ?

To set and get the input type date in dd-mm-yyyy format we will use <input> type attribute. The <input> type attribute is used to define a date picker or control field. In this attribute, you can set the range from which day-month-year to which day-month-year date can be selected from. If min and max values are not set then default min value is set to “01-01-1920” and default max value is set to “01-01-2120”.

Example 1: This example uses <input type=”date”> attribute to get the date in dd-mm-yyyy format.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        How to get input type date
        in dd-mm-yyyy format ?
    </title>
      
    <style>
        body {
            text-align: center;
        }
        h1 {
            color: green;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
      
    <h3>
        Get input date in
        dd-mm-yyyy format
    </h3>
      
    <label for="start">
        Enter the Date:
    </label>
  
    <input type="date" name="begin" 
        placeholder="dd-mm-yyyy" value=""
        min="1997-01-01" max="2030-12-31">
</body>
  
</html>

chevron_right


Output:

Example 2: This example uses <input type=”date”> attribute to get the date in dd-mm-yyyy format.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        How to get input type date
        in dd-mm-yyyy format ?
    </title>
      
    <style>
        body {
            text-align: center;
        }
        h1 {
            color: green;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
      
    <h3>
        Get input date in
        dd-mm-yyyy format
    </h3>
      
    <label for="Date of Birth">
        Enter the Date:
        <input type="date" name="date">
    </label>
</body>
  
</html>

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.