0

i want to format this date <b-button variant="outline-primary">{{getContract.contract_data.start_date}} | {{getContract.contract_data.end_date}}</b-button> Now it looks like this: enter image description here

I want it to be seen like this: enter image description here

how can i do?

I solved it with MomentJS: Convert date format in Javascript using VueJS

Fabrizio
  • 63
  • 2
  • 9
  • It seems like you're receiving the date as a string: what about tackling it at the source and ensuring that a unix timestamp (in ms) is being used? Then it is a matter of passing that number to the `Date()` object and using `toLocaleString` to format it any way you like. – Terry Jan 10 '22 at 09:11
  • Thanks @Terry how can i do this? – Fabrizio Jan 10 '22 at 09:14
  • Ensure that your `contract_data`'s `start_date` and `end_date` are unix timestamps not strings, convert it to a date object, i.e. `new Date(getContract.contract_data.start_date)`, then read this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString – Terry Jan 10 '22 at 09:16
  • Do you know momentJS? – Mai Truong Jan 10 '22 at 09:25
  • 2
    https://stackoverflow.com/questions/46708110/convert-date-format-in-javascript-using-vuejs – Mai Truong Jan 10 '22 at 09:27
  • @Fabrizio Whenever answering (or solving) your question, please post an answer so that it can be easily found by other developers that might have the same question – Bruno Francisco Jan 10 '22 at 14:05
  • I strongly suggest you to use dayjs instead, or luxon, momentjs is not getting any further support… and actually authors recommend to migrate to other solutions instead. – NaturalDevCR Jan 11 '22 at 05:18

0 Answers0