Change the date format using js or jquery

How to change the date format of input?

Here is the example that may help you.

let's say you have date in Y-m-d = 2018-10-01 which you want to convert into "d-m-Y" = 01-10-2018

There may be many solutions for this as per different programming languages. 

The below example is for javascript.

var date = '2018-10-01';

var dateAr = date.split('-');

var newDate = dateAr[2] + '-' + dateAr[1] + '-' + dateAr[0]; 

the newDate variable will have this value "01-10-2018"

 

Thank You.

Other posts