function - Javascript convert date format from "yyyy-mm-dd" to "December 11th, 2013"? -
how make sintax convert date format default format (yyyy-mm-dd) english format december 11th, 2013 using javascript function?
thank you
var str_date = "1983-24-12", arr_date = str_date.split('-'), months = ['', 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; var new_date=months[arr_date[2]] + ' ' + arr_date[1] + ', ' + arr_date[0]);
edit
you can add ordinal using following:
function addordinal(n) { var ord = [,'st','nd','rd']; var = n%100; return n + (ord[a>20? a%10 :a] || 'th'); }
e.g.
addordinal(1); // 1st
Comments
Post a Comment