How to convert the given date to format.
Input: Sun, 11 Jun 2017 14:14:37 GMT
Output: 11-06-17 DD-MM-YY
I have tried split
and then the mapping of month text to month number.
How to convert the given date to format.
Input: Sun, 11 Jun 2017 14:14:37 GMT
Output: 11-06-17 DD-MM-YY
I have tried split
and then the mapping of month text to month number.
You can do it like this:
var input = "Sun, 11 Jun 2017 14:14:37 GMT";
console.log(new Date(input).toJSON().replace(/^.*(\d\d)-(\d\d)-(\d\d).*$/, '$3-$2-$1'));