How to customize date format in HTML date input tag?
P粉709644700
P粉709644700 2023-08-21 14:15:32
0
1
601
<p>I would like to know if it is possible to set the date format in the <code><input type="date"></input></code> tag in html... currently it is yyyy-mm -dd format, and what I need is dd-mm-yyyy format. </p>
P粉709644700
P粉709644700

reply all(1)
P粉505917590

I found the same question or related question on stackoverflow

I found a simple solution, you can't give a specific format, but you can customize it as follows.

HTML code:

<body>
<input type="date" id="dt" onchange="mydate1();" hidden/>
<input type="text" id="ndt"  onclick="mydate();" hidden />
<input type="button" Value="Date" onclick="mydate();" />
</body>

CSS code:

#dt{text-indent: -500px;height:25px; width:200px;}

Javascript code:

function mydate()
{
  //alert("");
document.getElementById("dt").hidden=false;
document.getElementById("ndt").hidden=true;
}
function mydate1()
{
 d=new Date(document.getElementById("dt").value);
dt=d.getDate();
mn=d.getMonth();
mn++;
yy=d.getFullYear();
document.getElementById("ndt").value=dt+"/"+mn+"/"+yy
document.getElementById("ndt").hidden=false;
document.getElementById("dt").hidden=true;
}

Output:

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template