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 wondering if anyone knows how to show on website current date in format: dd/mm/yyyy
Currently I've tried this:
<p id="date"></p> <script> document.getElementById("date").innerHTML = Date(); </script>
And this works, but it displays date likes this:
Sat Sep 12 2015 16:40:10 GMT+0200 (Timezone.... )
Current Date and Time is stored inside javascript variable. Then using TextContent property the content of HTML span element is set with current and time. Unique ID is given to span tag so that we can use it on getElementById() method to dispaly the current date and time.
<input type="text" name="frmDateReg" required id="frmDate" value=""> function getDate(){ var todaydate = new Date(); var day = todaydate. getDate(); var month = todaydate.
dd-mm-yyyy. mm-dd-yyyy.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With