Kyler Phillips Kyler Phillips - 2 months ago 12x
Javascript Question

How to get current date in ddth/mm/yyyy format using JQuery

How can I get the current date in JQuery as a variable and then append to a heading in with an id of

, with the format
24th July 2016


You need to use javascript 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();

<script src=""></script>
<div id="currentdate"></div>