最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

momentjs - How to convert Thai date format to English using javascript? - Stack Overflow

programmeradmin2浏览0评论

I'm using bootstrap-datetimepicker and moment.js to manipulate the date and to generate a report. My application is capable of changing English to Thai language. The questions is how to convert this sample string "24-มิ.ย.-2015 00:00:00" to "24-June-2015 00:00:00" Pls. someone help how to do this in javascript?

I'm using bootstrap-datetimepicker and moment.js to manipulate the date and to generate a report. My application is capable of changing English to Thai language. The questions is how to convert this sample string "24-มิ.ย.-2015 00:00:00" to "24-June-2015 00:00:00" Pls. someone help how to do this in javascript?

Share Improve this question asked Jun 25, 2015 at 7:37 King AgustinKing Agustin 611 gold badge4 silver badges9 bronze badges 1
  • 1 Use a conversion table between Thai and English month names. – Bergi Commented Jun 25, 2015 at 7:41
Add a ment  | 

1 Answer 1

Reset to default 2

var monthNamesThai = ["มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน",
"กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤษจิกายน","ธันวาคม"];

var dayNames = ["วันอาทิตย์ที่","วันจันทร์ที่","วันอังคารที่","วันพุทธที่","วันพฤหัสบดีที่","วันศุกร์ที่","วันเสาร์ที่"];

var monthNamesEng = ["January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December"];

var dayNamesEng = ['Sunday','Monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];

var d = new Date();

document.write("The current Date is  " + dayNames[d.getDay()]+"  "+d.getDate()+""+monthNamesThai[d.getMonth()]+"  "+d.getFullYear()+" = "+ dayNamesEng[d.getDay()]+" "+d.getDate()+" " + monthNamesEng[d.getMonth()]+"  "+d.getFullYear());

发布评论

评论列表(0)

  1. 暂无评论