<input type="date" id="dateInput" />
<button onclick="formatDate()">Format Date</button>
<script>
function formatDate() {
const dateInput = document.getElementById("dateInput").value; // YYYY-MM-DD
if (dateInput) {
const [year, month, day] = dateInput.split("-");
const formattedDate = `${day}/${month}/${year}`; // Convert to DD/MM/YYYY
alert("Formatted Date: " + formattedDate);
} else {
alert("No date selected");
}
}
</script>
Post a Comment