You can use Moment.js library to format dates easily. First, create a Moment object with the date string and then format it using the format
method as follows:
index.tsx178 chars4 lines
In the format
method, MMMM
represents the full month name, DD
represents the day of the month with leading zeros, YYYY
represents the four-digit year, h
represents the hour in 12-hour format, mm
represents the minutes with leading zeros, ss
represents the seconds with leading zeros, and a
represents either am
or pm
.
gistlibby LogSnag