0

Does anyone know how to format this MySQL response to have JUST the date in the format of MM-DD-YYYY? For example, I want the below response to be formatted in 12-02-2020

date: '2020-12-02T08:00:00.000Z'

I tried doing the lines below but didn't seem to work

let formattedDate = new Date(Date.parse(entry.date.replace(/-/g, '/')));
SamuelP
  • 175
  • 2
  • 2
  • 8
  • The duplicate question is almost exactly what you need. Just replace `[year, month, day]` with `[month, day, year]`. – str Dec 03 '20 at 21:32

1 Answers1

0

You can use date_format() in your SQL query:

date_format(mydate, '%m-%d-%Y')
GMB
  • 216,147
  • 25
  • 84
  • 135