Date format conversion in Javascript

kalaivani M

kalaivani M

@kalaivani-m-Y29OXC Oct 26, 2024
i have coded to convert the date format dd/mm/yyyy to ddmmyyyy in javascript but its not working . i have attached my snippet here, kindly tell me what mistake i have done here.



<html>
<body>

<input type="date" id="id1"/>
<button onclick="myfunction()">click me</button>

<p id="id2"></p>
<script>
function myfunction()
{

var date=document.getElementById("id1").value;
date=date.format('DDMMYYYY');

document.getElementById("id2").innerHTML=date;
}

</script>
</body>
</html>

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform