Welcome to W3Courses
 Like Us on Facebook

Display Current Date Automatically on your Website using JavaScript

The following code displays the current date with month and year in the following format:

September 20, 2007

<!-- //Hide From Old Browsers

   Do Not Remove the Following Line
   For more scripts visit http://www.w3courses.com

var d=new Date();
var y=d.getYear();
if (y < 1000)
var day=d.getDay();
var m=d.getMonth();
var daym=d.getDate();
if (daym<10)
var mon=new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
document.write("<font size='2' color='red'>"+mon[m]+" "+daym+", "+y+"</font>");

// End Hide -->