diff --git a/public/dashboard/event.html b/public/dashboard/event.html
index d076cd9..afb1d33 100644
--- a/public/dashboard/event.html
+++ b/public/dashboard/event.html
@@ -842,10 +842,18 @@
setInterval(updateRealtimeStatus, 1000);
// Helper function untuk mendapatkan tanggal hari ini dalam timezone Indonesia (UTC+7)
+ // Menggunakan Intl.DateTimeFormat untuk mendapatkan tanggal yang konsisten di semua browser
function getTodayIndonesia() {
const now = new Date();
- const indonesiaTime = new Date(now.getTime() + (7 * 60 * 60 * 1000)); // UTC+7
- return indonesiaTime.toISOString().split('T')[0];
+ // Format tanggal dalam timezone Asia/Jakarta (UTC+7)
+ const formatter = new Intl.DateTimeFormat('en-CA', {
+ timeZone: 'Asia/Jakarta',
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit'
+ });
+ // Format: YYYY-MM-DD
+ return formatter.format(now);
}
// Init
diff --git a/public/dashboard/js/dashboard.js b/public/dashboard/js/dashboard.js
index 5521da5..6d72081 100644
--- a/public/dashboard/js/dashboard.js
+++ b/public/dashboard/js/dashboard.js
@@ -20,10 +20,18 @@ import {
} from './charts.js';
// Helper function untuk mendapatkan tanggal hari ini dalam timezone Indonesia (UTC+7)
+// Menggunakan Intl.DateTimeFormat untuk mendapatkan tanggal yang konsisten di semua browser
function getTodayIndonesia() {
const now = new Date();
- const indonesiaTime = new Date(now.getTime() + (7 * 60 * 60 * 1000)); // UTC+7
- return indonesiaTime.toISOString().split('T')[0];
+ // Format tanggal dalam timezone Asia/Jakarta (UTC+7)
+ const formatter = new Intl.DateTimeFormat('en-CA', {
+ timeZone: 'Asia/Jakarta',
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit'
+ });
+ // Format: YYYY-MM-DD
+ return formatter.format(now);
}
// State akan di-set ke hari ini saat DOMContentLoaded
@@ -76,10 +84,15 @@ async function getLastAvailableDate() {
// Jika tidak ada data kemarin, cek 7 hari terakhir (gunakan timezone Indonesia UTC+7)
const now = new Date();
- const indonesiaTime = new Date(now.getTime() + (7 * 60 * 60 * 1000)); // UTC+7
+ const formatter = new Intl.DateTimeFormat('en-CA', {
+ timeZone: 'Asia/Jakarta',
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit'
+ });
for (let i = 2; i <= 7; i++) {
- const prevDate = new Date(indonesiaTime.getTime() - (i * 24 * 60 * 60 * 1000));
- const prevDateStr = prevDate.toISOString().split('T')[0];
+ const prevDate = new Date(now.getTime() - (i * 24 * 60 * 60 * 1000));
+ const prevDateStr = formatter.format(prevDate);
const prevData = await apiGetSummary({ date: prevDateStr });
console.log(`[Dashboard] getLastAvailableDate - ${i} days ago (${prevDateStr}) data:`, prevData);
diff --git a/public/dashboard/js/realtime.js b/public/dashboard/js/realtime.js
index bf34c9f..c32cab4 100644
--- a/public/dashboard/js/realtime.js
+++ b/public/dashboard/js/realtime.js
@@ -94,8 +94,14 @@ class RealtimeManager {
// Struktur response setelah di-unwrap: { total_count_today, total_amount_today, by_gate, by_category }
// Gunakan timezone Indonesia UTC+7 untuk mendapatkan tanggal lokal yang benar
const now = new Date();
- const indonesiaTime = new Date(now.getTime() + (7 * 60 * 60 * 1000)); // UTC+7
- const today = indonesiaTime.toISOString().split('T')[0];
+ // Format tanggal dalam timezone Asia/Jakarta (UTC+7)
+ const formatter = new Intl.DateTimeFormat('en-CA', {
+ timeZone: 'Asia/Jakarta',
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit'
+ });
+ const today = formatter.format(now);
const snapshot = await apiGetRealtimeSnapshot({
date: today,
location_code: '' // bisa diambil dari state dashboard jika perlu