I am using website builder called \'clickfunnels\', and they don\'t support feature that would allow me to display current date. But, I can add custom html to it.
I was
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"
var currentDate = new Date(),
currentDay = currentDate.getDate() < 10
? '0' + currentDate.getDate()
: currentDate.getDate(),
currentMonth = currentDate.getMonth() < 9
? '0' + (currentDate.getMonth() + 1)
: (currentDate.getMonth() + 1);
document.getElementById("date").innerHTML = currentDay + '/' + currentMonth + '/' + currentDate.getFullYear();
You can read more about Date object
This helped me:
<p>Date/Time: <span id="datetime"></span></p><script>var dt = new Date();
document.getElementById("datetime").innerHTML=dt.toLocaleString();</script>
<script >
window.onload = setInterval(clock,1000);
function clock()
{
var d = new Date();
var date = d.getDate();
var year = d.getFullYear();
var month = d.getMonth();
var monthArr = ["January", "February","March", "April", "May", "June", "July", "August", "September", "October", "November","December"];
month = monthArr[month];
document.getElementById("date").innerHTML=date+" "+month+", "+year;
}
I prefer to use
<input type='date' id='hasta' value='<?php echo date('Y-m-d');?>'>
that works well