Source code Date.prototype.formatDateString = function(dateStr) { var month = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var shortMonth = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; var day = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; var shortDay = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]; var suffix = [ "st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th", "st" ]; var s = dateStr.replace("{$day}", day[this.getDay()]). replace("{$shortDay}", shortDay[this.getDay()]). replace("{$date}", this.getDate()). replace("{$suffix}", suffix[this.getDate()-1]). replace("{$monthNum}", this.getMonth()+1). replace("{$month}", month[this.getMonth()]). replace("{$shortMonth}", shortMonth[this.getMonth()]). replace("{$year}", this.getFullYear()). replace("{$shortYear}", (""+this.getFullYear()).substring(2)); return s; } var now = new Date(); document.writeln("" + now.formatDateString("{$monthNum}/{$date}/{$shortYear}") + ""); document.writeln("" + now.formatDateString("{$month} {$date}{$suffix}, {$year}") + ""); document.writeln("" + now.formatDateString("{$day}, {$shortMonth} {$date}, {$year}") + ""); document.writeln("" + now.formatDateString("{$shortDay} the {$date}{$suffix} of {$month}, {$year}") + "");