简体   繁体   English

将日期从一种语言转换为另一种语言

[英]Converting a date from one language to another

I have a date in Thai as: 我有一个泰文约会:

31มี.ค.2017, 16:56:51

which translates to 转化为

Mar 31, 2017, 16:56:51

using google translate. 使用谷歌翻译。 Is there a way, I could do this using momentjs locale support? 有没有办法,我可以使用momentjs语言环境支持来做到这一点? If not, is there any other way out? 如果没有,还有其他出路吗?

Momentjs suports i18n and supports Thai [th] locale, you can parse your input using moment(String, String, String) . Momentjs支持i18n并支持泰语[th]语言环境,您可以使用moment(String, String, String)解析输入。

Then you can use locale() and format() to show the value using english locale. 然后,您可以使用locale()format()来使用英语语言环境显示值。

Here a working sample: 这是一个工作示例:

 var m = moment('31มี.ค.2017, 16:56:51', 'DDMMMMYYYY, HH:mm:ss', 'th'); console.log(m.locale('en').format('MMM DD, YYYY, HH:mm:ss')); // Mar 31, 2017, 16:56:51 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment-with-locales.min.js"></script> 

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

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