I am trying (and failing!) to format my date output using javascript, so I am asking for some help.
The date format is 2013-12-31 (yyyy-mm-dd), but I want to display the date as 12-2013 (mm-yyyy).
I have read many posts, but I am now just confused.
Here is the call to the javascript function:
changeDateFormat($('#id_award_grant_date').val()),
Here is the javascript function:
function changeDateFormat(value_x){
}
What you have is just a string, so just split it and put it back together in the wanted format
var date = '2013-12-31',
parts = date.split('-'),
new_date = parts[1]+'-'+parts[0];
FIDDLE
var d = '2013-12-31'
var yyyymmdd = d.split('-')
var mmyyyy = yyyymmdd[1]+'-'+yyyymmdd[0]; // "12-2013"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With