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 am passing in the time from the results of a Breeze EntityQuery where the time is a 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");
}
Whether I use A or a in the formatting, I still end up with the following:
06/15/2015 9:00 上午
Is there something else I need to add? Thank you in advance!!
However, Moment. js has too many drawbacks compared to modern date and time libraries. Its API is not immutable, it is large and it doesn't support tree shaking. Even the Moment team discourages to use their library in new projects.
Moment. js is a fantastic time & date library with lots of great features and utilities. However, if you are working on a performance sensitive web application, it might cause a huge performance overhead because of its complex APIs and large bundle size. Problems with Moment.
To force the English locale globally, add
moment.locale('en');
to your code.
To configure it for a specific moment
instance, you could also use
moment(value).locale('en').format(/* ... */);
in your function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With