Here's a simple set of functions to display the clients date. With the internet being a global system,
displaying the date on server may bear no resemblence to the clients date. Not everyone lives by US Eastern
Standard Time, so the following script will give your pages a little more local content than is possible
using server side scripting.
var Days = new Array("Sunday","Monday","Tuesday","Wednesday",
var Months = new Array("January","February","March","April","May","June",
var Today = new Date();
var suffix = "th";
suffix = "st"; break;
suffix = "nd"; break;
suffix = "rd"; break;
var strDate = GetDay(Today.getDay()) + " " + Today.getDate();
strDate += suffix + " " + GetMonth(Today.getMonth()) + ", " + Today.getYear();
To use this in your web pages, just include the above script somewhere, and add the following
document.write("<p>Today is " + DateString() + "</p>\n");
Chris is the Co-founder, Administrator, Architect, Chief Editor and Shameless Hack who wrote and runs The Code Project. He's been programming since 1988 while pretending to be, in various guises, an astrophysicist, mathematician, physicist, hydrologist, geomorphologist, defence intelligence researcher and then, when all that got a bit rough on the nerves, a web developer. He is a Microsoft Visual C++ MVP both globally and for Canada locally.
His programming experience includes C/C++, C#, SQL, MFC, ASP, ASP.NET, and far, far too much FORTRAN. He has worked on PocketPCs, AIX mainframes, Sun workstations, and a CRAY YMP C90 behemoth but finds notebooks take up less desk space.
He dodges, he weaves, and he never gets enough sleep. He is kind to small animals.
Chris was born and bred in Australia but splits his time between Toronto and Melbourne, depending on the weather. For relaxation he is into road cycling, snowboarding, rock climbing, and storm chasing.