Need to show AM / PM with MomentJS

I am trying to format some dates using MomentJS. I have no problem until I try to add AM / PM or am / pm. I have the following function and from time to time is passed from the Breeze EntityQuery results, where time is System.DateTime, as shown:

function datetimeCellRendererFunc(value) { // value = Mon Jun 15 2015 09:00:00 GMT-0500 (Central Daylight Time); return moment(value).format("MM/DD/YYYY h:mm A"); } 

I use A or in formatting, I still get the following:

06/15/2015 9:00 上午

Is there anything else I need to add? Thanks in advance!

+5
source share
1 answer

To make the global English language globally add

 moment.locale('en'); 

to your code.

To customize it for a specific instance of moment , you can also use

 moment(value).locale('en').format(/* ... */); 

in your function.

0
source

All Articles