简体   繁体   English

使用Moment.js在特定语言环境中格式化日期

[英]Using momentjs to format a date in a specific locale

I have a global locale variable based on a user's preference. 我有一个基于用户偏好的全局语言环境变量。 When I pass that variable to moment along with a timestamp, it still displays the date in English. 当我将该变量以及时间戳传递给当前时刻时,它仍以英文显示日期。 I'd like it to display the date in the common format for that locale. 我希望它以该区域设置的通用格式显示日期。 For example: 例如:

moment.locale('fr');
console.log(moment(867283200, "X").format('LL')); //still outputs June 25, 1997 when it should be using French months

Any suggestions? 有什么建议么?

Figured it out. 弄清楚了。 I just needed to load the locales in the browser using the locales.min.js available here: https://github.com/moment/moment/tree/develop/min 我只需要使用可在此处使用的locales.min.js在浏览器中加载语言环境: https : //github.com/moment/moment/tree/develop/min

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM