Search code examples
javascriptdate-fns

Extra word between date and time with date-fns


I am looking for a way to add an extra word between the date and time in date-fns library, but couldn't find such format. Right now I am using format function with MMM d hh:mm aa format.

The outcome is: Nov 15 10:00 PM

Is there a way to get: Nov 15 at 10:00 PM


Solution

  • I'd highly recommend reading and understanding the docs, before posting a question as simple as this.

    As per documentation for the latest version (as of writing 2.29.3) the following will yield the required result.

    format(new Date("Sep 2 2020 13:00"), "MMM dd 'at' HH:MM a")