How to change date format using jQuery?
date-format, javascript, jquery
Solution
You can use date.js to achieve this:
var date = new Date('2014-01-06');
var newDate = date.toString('dd-MM-yy');
Alternatively, you can do it natively like this:
var dateAr = '2014-01-06'.split('-');
var newDate = dateAr[1] + '-' + dateAr[2] + '-' + dateAr[0].slice(-2);
console.log(newDate);
Problem
I have a date in a format like this `fecha2.value = '2014-01-06'`, but I want to change the format to this `'01-06-14'` using jQuery. How can I do this?