-
-
Save icesernia/6ee8ce4fc4c7e0f25ab4f37dc7a7664f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let date = new Date(); | |
let options = { weekday: 'long', year: 'numeric', month: 'short', day: 'numeric', timeZone: 'Asia/Bangkok' } | |
console.log(new Intl.DateTimeFormat('en-US', options).format(date)); // expected output: Saturday, Feb 20, 2021 | |
console.log(new Intl.DateTimeFormat('th-TH', options).format(date)); // expected output: วันเสาร์ที่ 20 ก.พ. 2564 | |
console.log(new Intl.DateTimeFormat('th-TH-u-nu-thai', options).format(date)); // expected output: วันเสาร์ที่ ๒๐ ก.พ. ๒๕๖๔ | |
let options2 = { hour: '2-digit', minute: '2-digit' } | |
console.log(new Intl.DateTimeFormat('th-TH', options2).format(date)); // expected output: 21:05 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment