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]); 

http://jsfiddle.net/tn7ne/

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

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -