相对时间本土化支持 “second”, “minute”, “hour”, “day”, “week”, “month”, “quarter”, “year"var rtf = new Intl.RelativeTimeFormat(‘zh-Hans-CN’,{numeric: “auto”});rtf.format(-1, “day”);//“昨天"rtf.format(-2, “day”);//“前天"var rtf = new Intl.RelativeTimeFormat(“en”, { numeric: “auto” });rtf.format(-1, “day”);// “yesterday"rtf.format(1, “day”);//“tomorrow"数字本土化分组逗号分隔(1234.2345).toLocaleString(’en-US’,{useGrouping:true});//“1,234.235"科学计数保留位(1234.2345).toLocaleString(‘zh-CN’, {style:‘decimal’,maximumSignificantDigits:2});//“1,200"小数保留位(1234.2345).toLocaleString(‘zh-CN’, { style: ‘decimal’,maximumFractionDigits:3});//“1,234.235"百分制(1234.2345).toLocaleString(‘zh-CN’, { style: ‘percent’,maximumFractionDigits:2});//“123,423.45%“货币(1234.23).toLocaleString(‘zh-CN’, { style: ‘currency’,currency:“CNY”, currencyDisplay:“symbol”, maximumFractionDigits:2});//"¥1,234.23”(1234.23).toLocaleString(‘zh-CN’, { style: ‘currency’,currency:“CNY”, currencyDisplay:“code”, maximumFractionDigits:2});//“CNY 1,234.23”(1234.23).toLocaleString(‘zh-CN’, { style: ‘currency’,currency:“CNY”, currencyDisplay:“name”, maximumFractionDigits:2});//“1,234.23 人民币"汉字(1234567890).toLocaleString(‘zh-Hans-CN-u-nu-hanidec’,{useGrouping:false})//“一二三四五六七八九〇”(123456.0199).toLocaleString(‘zh-Hans-CN-u-nu-hanidec’)//“一二三,四五六.〇二"日期时间本土化var date=new Date(Date.UTC(2012, 11, 20, 3, 0, 0))Intl.DateTimeFormat(’en-US’).format(date)//“12/20/2012"Intl.DateTimeFormat(’en-GB’).format(date)//“20/12/2012"Intl.DateTimeFormat(‘ko-KR’).format(date)//“2012. 12. 19.“Intl.DateTimeFormat(‘ar-EG’).format(date)//“‏/‏/“时间本土化date.toLocaleTimeString(‘zh-Hans-CN’)//“上午11:00:00"日期本土化date.toLocaleDateString(‘zh-Hans-CN’)“2012/12/20"Date.prototype.tiLiocaleString 配置项date.toLocaleString(‘zh-Hans-CN’,{ year:“numeric”, month:“2-digit”, day:“2-digit”, weekday:“long”, hour:“2-digit”, minute:“2-digit”, second:“2-digit”, hour12: false, timeZone:“Asia/Shanghai”, })//“2012年12月20日星期四 11:00:00"Intl格式化(含时区转换)Intl.DateTimeFormat(‘zh-Hans-CN’,{ year:“numeric”, month:“2-digit”, day:“2-digit”, hour:“2-digit”, minute:“2-digit”, second:“2-digit”, hour12: false, timeZone:“Asia/Shanghai” }).format(date);//“2012/12/20 11:00:00"Intl格式化分片Intl.DateTimeFormat(‘zh-Hans-CN’,{ year:“numeric”, month:“2-digit”, day:“2-digit”, hour:“2-digit”, minute:“2-digit”, second:“2-digit”, hour12: false, timeZone:“Asia/Shanghai”, }).formatToParts(date)/0: {type: “year”, value: “2012”}1: {type: “literal”, value: “/"}2: {type: “month”, value: “12”}3: {type: “literal”, value: “/"}4: {type: “day”, value: “12”}5: {type: “literal”, value: " “}6: {type: “hour”, value: “11”}7: {type: “literal”, value: “:"}8: {type: “minute”, value: “00”}9: {type: “literal”, value: “:"}10: {type: “second”, value: “00”}/农历阳历转换Intl.DateTimeFormat(‘zh-Hans-CN-u-ca-chinese’).format(date);//“29/11/8”//备注:农历壬辰年 十一月初八zhMon=[’ 甲乙丙丁戊己庚辛壬癸’,’ 子丑寅卯辰巳午未申酉戌亥’]zhMon[0][29%10]+zhMon[1][29%12]//壬辰date.toLocaleString(‘zh-Hans-CN-u-ca-chinese’)//“29/11/8 上午11:00:00"星期文案转换(new Date(‘2001-01-01’)).toLocaleString(‘zh-Hans-CN’,{weekday:“long”})//“星期一”(new Date(‘2001-01-07’)).toLocaleString(‘zh-Hans-CN’,{weekday:“short”})//“周日”