Kyler Phillips Kyler Phillips - 1 year ago 110
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

Answer Source

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>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download