Moment.js display hour in local format

Viewed 5106

I guess this is quite simple question, but I am currently unable to find it in moment's documentation. I have to display just an hour in local format, e.g.

  • for locale en-gb: 14
  • for locale en-us: 2 PM

The closest format I've found is LT, but it also displays minutes that are not desired...

Here is what I tried:

moment().format('LT'); // 14:00 / 2:00 PM
// I need some kind of combination of these two:
moment().format('H'); // 14
moment().format('h A'); // 2 PM

Is there a moment-way to achieve it or am I forced to use a work-around like below?

moment().format('LT').replace(/:[0-9]{2}/, '');
4 Answers
Related