Angular.js: Date filter am/pm case

Created on 25 Aug 2014  路  7Comments  路  Source: angular/angular.js

The current documentation for the date filter is inconsistent about the case of the 'a' AM/PM format - the output is uppercase, but the docs mostly show lowercase, which is misleading. Other than fixing the docs, it would be great to actually support the two different formatting options, e.g. 'a' for uppercase and 'A' for lowercase (the inverse would be more intuitive, but 'a' is already used for uppercase, so for backward compatibility's sake... or just use a different letter for lowercase).

PRs plz! docs

Most helpful comment

You can use lowercase filter after date to convert am/pm to lowercase.

For example: 1288323623006 | date: "h:mma" | lowercase will produce "5:40am"

Although I agree with you that a/A notations would be much better.

All 7 comments

Would you like to submit a PR for this? :D

@btford This information is picked from the CLDR that

  • Already defines the format using 'a' for the AMPMS symbol
  • Does not have a lower case version of AMPMS

I am not sure what are the document issues, keeping this issue open to get more information on this last part

The documentation issues are the ones fixed in #8780 above, i.e. that all examples show lowercase am/pm whereas the actual format is uppercase.

@amichair thanks, landed as 7a36d4953316a1833bcd787c5763d0cc78eb0b1e

Thanks @SekibOmazic for actually doing it :-)

You can use lowercase filter after date to convert am/pm to lowercase.

For example: 1288323623006 | date: "h:mma" | lowercase will produce "5:40am"

Although I agree with you that a/A notations would be much better.

It is also possible to inject and modify $locale service: $locale.DATETIME_FORMATS.AMPMS = ['am', 'pm'];
See plunker: https://plnkr.co/edit/a49kjvOdifXPAvBlmXEi?p=preview

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jtorbicki picture jtorbicki  路  3Comments

jetta20162 picture jetta20162  路  3Comments

butchpeters picture butchpeters  路  3Comments

brijesh1ec picture brijesh1ec  路  3Comments

nosideeffects picture nosideeffects  路  3Comments