You can format a date into the desired format using Moment.js library.
Here's an example:
index.tsx215 chars8 lines
Explanation:
Date
object to represent the current date and time.moment()
function from Moment.js library to create a new Moment object from the Date
object.format()
function with the desired format string: 'MMMM DD, YYYY h:mm a'
. This format string represents the format "month day, year hour:minute am/pm".gistlibby LogSnag