Can’t get DD-MM-YYYY date format in Vuejs from mysql

Hey I receive dateCreated (the date when the account was created) and I can’t find how to set it to DD-MM-YYYY.

In my Vue page the code is:

enter image description here

The problem is that the website shows me the date in this format:

enter image description here

But I really don’t want YYYY-MM-DD T HH-MM-SS-SSS. I just want DD-MM-YYYY. Here this is mysql column of dateCreated:

enter image description here

Would really appreciate help, thanks


You could format it in MySQL:

SELECT DATE_FORMAT(dateCreated, "%d-%m-%Y") AS dateCreated

Or you could use a Vue computed:

computed: {
  formatted() {
    const myDate = this.membre.dateCreated;
    const formatted = ('0' + myDate.getDate()).slice(-2) + '/'
             + ('0' + (myDate.getMonth()+1)).slice(-2) + '/'
             + myDate.getFullYear();
    return formatted;