function formatDate (theDate) {
var originalDate = new Date(theDate),
date = originalDate.getDate(),
month = "January,February,March,April,May,June,July,August,September,October,November,December".split(",")[originalDate.getMonth()];
function nth(d) {
if(d>3 && d<21) return 'th';
switch (d % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
default: return "th";
}
}
return date+nth(date) + " " + month + " " + originalDate.getFullYear();
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.