Bootstrap input date format example
June 22, 2022Hi Friends 👋,
Welcome To aGuideHub! ❤️
To make an input date format, put the type="date"
attribute in an input element it will show the input type date format on a page.
Today, I am going to show you. how to create input date format button in bootstrap with code example.
This example uses <input type=”date”>
attribute to get the date in dd-mm-yyyy
format.
Table of contents
- Includes bootstrap view
- Includes bootstrap library
- Define its attribute name
This article will guide you to adding navbar in Bootstrap 5 with example.
Step 1: Includes bootstrap view
To ensure proper rendering and touch zooming for all devices, add the responsive viewport meta tag to your <head>
.
<meta name="viewport" content="width=device-width, initial-scale=1">
Step : Includes bootstrap library
First of all, load the Bootstrap 5 framework CSS into the head tag of your webpage.
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
Step 3: Define its attribute name
After that, create the input date format with a attribute name type="date"
.
<h1>aGuideHub</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">
Example.
Let’s look at the following example to understand how it basically works:
input-date-format-in-bootstrap.html
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>Bootstrap</title>
<style>
body {
text-align: center;
}
h1 {
color: #e72c99;
}
</style>
</head>
<body >
<h1>aGuideHub</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">
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
</body>
</html>
Check the output of the above code example.
All the best 👍