在基本使用沒有指定一個區域,在默認的語言環境,並使用默認選項格式化字符串回。
var date = new Date(Date.UTC(2012, 11, 12, 3, 0, 0));
// toLocaleString without arguments depends on the implementation,
// the default locale, and the default time zone
date.toLocaleString();
// "12/11/2012, 7:00:00 PM" if run in en-US locale with time zone America/Los_Angeles
使用本地化
var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
// formats below assume the local time zone of the locale;
// America/Los_Angeles for the US
// US English uses month-day-year order
alert(date.toLocaleString("en-US"));
// "12/19/2012, 7:00:00 PM"
// British English uses day-month-year order
alert(date.toLocaleString("en-GB"));
// "20/12/2012 03:00:00"
// Korean uses year-month-day order
alert(date.toLocaleString("ko-KR"));
// "2012. 12. 20. 오후 12:00:00"
「18-08-89」 是不是在 「DD-MM-YYYY」 格式,你嘗試過 「18-08-1989」? – darma 2013-05-02 12:57:52
http://blog.stevenlevithan.com/archives/date-time-format – xyz 2013-05-02 12:58:35
我改正了我的問題,是的,我已經嘗試過 – Kenci 2013-05-02 12:59:29