JS Intl API Format Date Number
Ringkasan
Intl menangani formatting lokal (tanggal, angka, mata uang, relatif) tanpa library eksternal.
Konsep Dasar
Intl.DateTimeFormat(locale).format(date).Intl.NumberFormat(locale, {style:'currency', currency:'IDR'}).Intl.RelativeTimeFormat— "3 jam lalu".Intl.ListFormat— "A, B, dan C".- Locale:
'id-ID','en-US'.
Cara Kerja / Struktur
new Intl.NumberFormat('id-ID',{style:'currency',currency:'IDR'}).format(15000);
// "Rp 15.000"
new Intl.DateTimeFormat('id-ID',{dateStyle: