HTML Display Current date
Here's one way. You have to get the individual components from the date object (day, month & year) and then build and format the string however you wish.
n = new Date();
y = n.getFullYear();
m = n.getMonth() + 1;
d = n.getDate();
document.getElementById("date").innerHTML = m + "/" + d + "/" + y;
<p id="date"></p>
Use Date::toLocaleDateString
.
new Date().toLocaleDateString()
= "9/13/2015"
You don't need to set innerHTML, just by writing
<p>
<script> document.write(new Date().toLocaleDateString()); </script>
</p>
will work.
P.S.
new Date().toDateString()
= "Sun Sep 13 2015"
I prefer to use
<input type='date' id='hasta' value='<?php echo date('Y-m-d');?>'>
that works well