Search code examples
javascriptdate-fns

How to skip some characters from formatting in date-fns


In the folowing example I want to say date-fns do not format at (skip these characters):

format(DATE, 'cccc, MMMM d at h:mm a')

Output is:

Thursday, August 8 AM492296400 12:30 AM

Expected is:

Thursday, August 8 at 12:30 AM

Solution

  • See the documentation:

    The characters wrapped between two single quotes characters (') are escaped.

    format(DATE, "cccc, MMMM d 'at' h:mm a")