Search code examples
javascriptdate-fns

How do you format a datetime to am/pm, without periods, when using date-fns version 2.x?


Version 2.x of the excellent date package date-fns only has these built-in am/pm formats.

date-fns am pm formats

How can I format the lower case am/pm without the periods?


Solution

  • You can now use the aaa pattern for that case (v.2.23.0).

    enter image description here

    Source: https://date-fns.org/v2.23.0/docs/format