Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App
Next Article:
How to specify the type of an input element using HTML ?
Next article icon

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

Last Updated : 26 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In HTML, you can use the <input> element with the type date to allow users to pick a date. However, the format used for displaying the date may vary depending on the browser and the user’s locale settings. By default, the browser uses the ISO format (yyyy-mm-dd), which is not the same as dd-mm-yyyy. Unfortunately, HTML itself doesn’t provide a way to directly set the date format to dd-mm-yyyy using the <input type=”date”> element.

Note: The default values for the min and max attributes are min=”01-01-1920″ and max=”01-01-2120″.

Using the type=”date” Attribute

The type=”date” attribute generates a date picker in compliant browsers. The displayed date format, however, isn’t consistent across all browsers and might differ depending on the browser’s settings.

Syntax

<input type="date">

Example 1: Basic Date Input

In this example, we set the input type as date, allowing users to pick a date from a calendar. However, the format of the date may vary depending on the user’s browser.

HTML
<html> <head>     <style>         body {             text-align: center;         }     </style> </head> <body>     <h3>Setting Input Type Date in dd-mm-yyyy Format</h3>     <label for="start">Enter the Date:</label>     <!-- Date input field -->     <input type="date" id="start" name="begin" value="" min="1997-01-01" max="2030-12-31"> </body> </html> 

Output:

input-type-date-in-dd-mm-yyyy-format-in-HTML

input type date in dd-mm-yyyy format using HTML Example Output

In this Example

  • min=”1997-01-01″ and max=”2030-12-31″ define the date range that users can choose from.
  • The format for the input field is displayed based on the browser’s locale and cannot be controlled directly with HTML alone.

Example 2: Date Picker with Range Attribute

In this example, we set a date picker where the range is defined using the min and max attributes, which restricts the user to selecting dates within this range. The date format is still determined by the browser and is typically in yyyy-mm-dd format.

HTML
<html> <head>     <style>         body {             text-align: center;         }     </style> </head>  <body>     <h3>Setting Input Type Date in dd-mm-yyyy Format</h3>     <label for="start">         Enter the Date:     </label>     <!-- Date input field -->     <input type="date" name="begin" value="" min="1997-01-01" max="2030-12-31">  </body> </html> 

Output:

input-type-date-in-dd-mm-yyyy-format-in-HTML

input type date in dd-mm-yyyy format using HTML Example Output

In this Example

  • min=”1997-01-01″: This restricts the user to selecting dates from January 1, 1997.
  • max=”2030-12-31″: This limits the user to selecting dates before December 31, 2030.
  • placeholder=”dd-mm-yyyy”: This is just a visual hint, but the date format will not enforce dd-mm-yyyy.


Next Article
How to specify the type of an input element using HTML ?

S

shubhampatni88
Improve
Article Tags :
  • HTML
  • Web Technologies
  • Write From Home
  • HTML-Misc
  • HTML-Questions

Similar Reads

  • How to Change input type="date" Format in HTML ?
    The <input> element with type="date" is used to allow the user to choose a date. By default, the date format displayed in the input field is determined by the user's browser and operating system settings. However, it is possible to change the format of the date displayed in the input field usi
    4 min read
  • How to set Placeholder Value for Input Type Date in HTML?
    To set a placeholder value for the input type date in HTML5, use the placeholder attribute. The placeholder attribute doesn't work well with input type "date." Use onfocus="(this.type='date')" for a custom placeholder, enabling a date selection dropdown. Using OnfocusThe On-focus approach changes th
    2 min read
  • How to set float input type in HTML5 ?
    HTML5 is the latest version of Hypertext Markup Language (HTML), the standard language for creating web pages and web applications. With HTML5, new input types were introduced to make web form creation easier and more accessible. These input types include text, password, checkbox, radio, submit, res
    3 min read
  • How to add a Time picker in Form using HTML5 ?
    In this article, we will see how to add a Time picker in Form using HTML5. As we know that a Time picker is used to provide tp select a single value from a pre-determined set. Basically, it creates an input field that accepts a time. We can open a time picker by clicking on a clock icon. The UI Desi
    1 min read
  • How to specify the type of an input element using HTML ?
    In this article, we will specify the type of an input element using HTML. The HTML <input> type attribute is used to specify the type of <input> element to display. The default type of <input> type attribute is text. Syntax: <input type="value"> Attribute Values: button: It i
    4 min read
  • How to format current date in MM/DD/YYYY HH:MM:SS format using JavaScript ?
    Given a date and the task is to format the current date in MM/DD/YYYY HH:MM:SS format. Here are a few of the most techniques discussed with the help of JavaScript. Approach 1: Store the current date in variable.Use the string concatenation technique to insert / and : in between the month-day and day
    2 min read
  • How to Format Datetime to YYYY-MM-DD HH:MM:SS in Moment.js?
    In Moment.js, formatting the date in the proper format is important for consistent data presentation and manipulation. The library provides various methods to handle and transform dates. You can use direct formatting with format(), manipulate ISO strings, or work with Unix timestamps to achieve the
    3 min read
  • How to add a date picker in form using HTML ?
    To add a date picker in a form using HTML, you can use the <input> element with the type attribute set to "date". A date picker is an interactive dropdown that makes it easy to choose the date from a calendar instead of typing it manually. In this article, we will learn how to add a date picke
    2 min read
  • How To Format JavaScript Date as yyyy-mm-dd?
    We use JavaScript built-in help methods from the Date class that help us to create a formatted version of the current date in the form of yyyy-mm-dd. These are the approaches used to format JavaScript date as yyyy-mm-dd. Table of Content Using the ISO String Method USing JavaScript Method1. Using th
    2 min read
  • How to format the current date in MM/DD/YYYY HH:MM:SS format using Node?
    The current date can be formatted by using Nodejs modules like Date Object or libraries like moment.js. Table of Content Using Node.js Date ObjectUsing Moment.js LibraryMethod 1: Using Node.js Date Object:The JavaScript Date Object can be used in the program by using the following command. const dat
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences