How can I get the current date in JQuery as a variable and then append to a heading in with an id of
24th July 2016
Date() object and method of it to getting current date and component of it.
var monthName = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; var date = new Date(); var dateStr = date.getDate() + "th " + monthName[date.getMonth()] + " " + date.getFullYear(); $("#currentdate").text(dateStr);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="currentdate"></div>