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.
fecha2.value = '2014-01-06'
'01-06-14'
How can I do this? Thanks in advance.
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);
1.4m articles
1.4m replys
5 comments
57.0k users