Date Calculator - Calculate Differences & Add Days
About this app
A fun and interactive date calculator that helps you calculate the difference between two dates and add days to a specific date.
Date Calculator - Calculate Differences & Add Days Date Calculator Start Date: End Date: Calculate Difference Select a Date: Days to Add: Add Days
Related apps
Put this on your site
Source
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Date Calculator - Calculate Differences & Add Days</title>
<meta name="description" content="A fun and interactive date calculator that helps you calculate the difference between two dates and add days to a specific date.">
<meta name="keywords" content="date calculator, date difference, add days, date functions, calendar">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.6.0/css/fontawesome.min.css" crossorigin="anonymous">
<script type="text/javascript">
try {
document.addEventListener("DOMContentLoaded", function() {
function calculateDateDifference() {
const startDate = new Date(document.getElementById('start-date').value);
const endDate = new Date(document.getElementById('end-date').value);
const diffTime = Math.abs(endDate - startDate);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
document.getElementById('date-difference-result').innerText = `Difference: ${diffDays} day(s)`;
}
function addDaysToDate() {
const baseDate = new Date(document.getElementById('base-date').value);
const daysToAdd = parseInt(document.getElementById('days-to-add').value, 10);
if (!isNaN(daysToAdd)) {
const newDate = new Date(baseDate);
newDate.setDate(newDate.getDate() + daysToAdd);
document.getElementById('date-add-result').innerText = `New Date: ${newDate.toDateString()}`;
} else {
document.getElementById('date-add-result').innerText = "Please enter a valid number of days.";
}
}
document.getElementById('calculate-diff-btn').onclick = calculateDateDifference;
document.getElementById('add-days-btn').onclick = addDaysToDate;
});
} catch (error) {
throw error;
}
</script>
<style>
body {
background: linear-gradient(to right, #ff7e5f, #feb47b);
color: #fff;
font-family: Arial, sans-serif;
}
#main-container {
padding: 20px;
border-radius: 10px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
background: rgba(0, 0, 0, 0.5);
}
h1 {
text-align: center;
margin-bottom: 30px;
}
.btn {
width: 100%;
margin-top: 10px;
}
.result {
margin-top: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>Date Calculator</h1>
<div class="mb-3">
<label for="start-date" class="form-label">Start Date:</label>
<input type="date" id="start-date" class="form-control" required>
</div>
<div class="mb-3">
<label for="end-date" class="form-label">End Date:</label>
<input type="date" id="end-date" class="form-control" required>
</div>
<button id="calculate-diff-btn" class="btn btn-primary">Calculate Difference</button>
<div id="date-difference-result" class="result"></div>
<hr class="my-4">
<div class="mb-3">
<label for="base-date" class="form-label">Select a Date:</label>
<input type="date" id="base-date" class="form-control" required>
</div>
<div class="mb-3">
<label for="days-to-add" class="form-label">Days to Add:</label>
<input type="number" id="days-to-add" class="form-control" required>
</div>
<button id="add-days-btn" class="btn btn-success">Add Days</button>
<div id="date-add-result" class="result"></div>
</div>
</body>
</html>
NEW APPS
These are apps made by the community!