Tambah fungsi formatRupiah
Menambahkan fungsi untuk memformat angka ke dalam format mata uang Rupiah. Perubahan ini juga menyertakan konsistensi penggunaan kutip ganda dalam fungsi format tanggal.
This commit is contained in:
parent
e8807e9233
commit
e0e9f39275
@ -42,25 +42,36 @@ document.querySelectorAll(".toastr").forEach((el) => {
|
||||
// Fungsi untuk memformat tanggal ke format Indonesia
|
||||
window.formatTanggalIndonesia = function (date) {
|
||||
const options = {
|
||||
weekday: 'long',
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric'
|
||||
weekday: "long",
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
};
|
||||
return new Date(date).toLocaleDateString('id-ID', options);
|
||||
return new Date(date).toLocaleDateString("id-ID", options);
|
||||
};
|
||||
|
||||
// Fungsi untuk memformat tanggal dan waktu ke format Indonesia
|
||||
window.formatTanggalWaktuIndonesia = function (date) {
|
||||
const options = {
|
||||
weekday: 'long',
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false
|
||||
weekday: "long",
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
hour12: false,
|
||||
};
|
||||
return new Date(date).toLocaleString('id-ID', options);
|
||||
return new Date(date).toLocaleString("id-ID", options);
|
||||
};
|
||||
|
||||
// Fungsi untuk memformat angka ke format Rupiah
|
||||
window.formatRupiah = function (angka) {
|
||||
const formatter = new Intl.NumberFormat("id-ID", {
|
||||
style: "currency",
|
||||
currency: "IDR",
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
});
|
||||
return formatter.format(angka);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user