[英]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.