Date format configuration in Vuejs/Quasar Framework

Asked

Viewed 2,495 times

1

I have a field for inserting the date of birth, and I want the insertion result to be formatted in 'DD-MM-YYYY'. I managed to have the date displayed in the desired format input, but when I send the date to the database it goes like this: "1997-08-19T00:00:00.000-03:00".

I created a function to format the date, but it didn’t work very well:

formatarData () {
    let data = this.pessoa.nascimento
    this.pessoa.nascimento = date.formatDate(data, 'DD-MM-YYYY')
  }

Now it is going to the bank like this: "Nan-Nan-0NaN", how to format so that it exits in the desired form??

  • That one "field for insertion" is it text or is it a calendar with dates to click? What is date in that second line?

  • It’s a Datetime, a calendar to click and choose dates, but I’ve already solved it using Moment.JS. And the date is a Vue import

  • Have you solved the question or the date input part? (and what is date that you have here date.formatDate(?)

  • I managed to solve the question as a whole. The date is a Vue resource, which can be used through a import, but I couldn’t do what I wanted using it, so I used Moment.JS, which worked perfectly.

  • Okay, so you can delete the question or give an answer. If you answer, you need to clarify the question further, because you still can’t tell from the outside.

  • Okay, I’ll answer her, so I can help someone who might need it in the future, feel free to edit it if you feel it’s necessary... Thank you for your attention

Show 1 more comment

1 answer

2


For those who need help, I was able to solve it this way:

formatarData () {
    let data = this.pessoa.nascimento
    this.pessoa.nascimento = moment(data).format('DD/MM/YYYY')
  }

I used the Momentjs to convert the date format. this.pessoa.nascimento refers to the object I am converting the date of birth.

I hope that clarification will be useful for more people as it was for me.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.