-3

what would be the best way to change the time format from the long string 2023-01-31T18:15:23.413003Z to something more human readable like 31 Jan, 2023 and also change the time to something like 18:15:24 and not the whole string? I already tried using the slice() method but how can i get the Name of the month and the number

    <td>{object.time_date.slice(0, 10)}</td>

1 Answers1

1

Use Intl.DateTimeFormat for date/time that way you don't have to worry about importing libraries or handling localization.

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
Stephen Gilboy
  • 5,572
  • 2
  • 30
  • 36
  • can you please help me sho, hov i can implement this quicky, i have done this `{Intl.DateTimeFormat().format(st.review_time)}` but it display invalid time in console – Destiny Franks Jan 31 '23 at 22:17
  • `new Intl.DateTimeFormat(undefined, { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric' }).format(new Date(st.review_time));` – Stephen Gilboy Jan 31 '23 at 22:32