[Vuejs]-How can i change date format in vue js template

0👍

Use the Date constructor to create the new date object from your date string. Then you can create the date in any custom format using this object. See the code below.

const input = "2019-01-08T11:11:00.000Z";

const dateObj = new Date(input);

const year = dateObj.getFullYear();
const month = (dateObj.getMonth()+1).toString().padStart(2, '0');
const date = dateObj.getDate().toString().padStart(2, '0');

const result = `${year}-${month}-${date}`;

console.log(result);

Leave a comment