I am trying to get the full date with my function. Right now my results are "Wed Feb 14 2018", but I would like it to say "Wednesday February 2018". I want it to say the whole day and whole month. I could not find a "get fullDate" method unfortunately..
window.onload = function() {
var date = new Date();
document.getElementById("date").innerHTML = date.toDateString();
}
<div id="date"> </div>
You're actually looking for the toLocaleString function, as it can be customized pretty heavily without losing your date object.
window.onload = function() {
var date = new Date();
document.getElementById("date").innerHTML = date.toLocaleString('en-US', {weekday: 'long', month: 'long', year: 'numeric'});
}
<div id="date"> </div>
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