change timestamp

This commit is contained in:
kicap
2025-07-16 20:22:18 +08:00
parent c2691fa35e
commit ec6f214d96

View File

@ -80,21 +80,27 @@
<script>
const utcString = "Wed, 16 Jul 2025 20:17:45 GMT";
const date = new Date(utcString);
function formatToMakassar(utcStr) {
const options = {
timeZone: 'Asia/Makassar',
year: 'numeric',
month: 'short',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
weekday: 'short',
hour12: false,
};
// Format to Asia/Makassar timezone
const formatter = new Intl.DateTimeFormat('en-US', {
timeZone: 'Asia/Makassar',
year: 'numeric',
month: 'short',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
weekday: 'short',
hour12: false,
});
const date = new Date(utcStr);
const formatter = new Intl.DateTimeFormat('en-US', options);
const parts = formatter.formatToParts(date);
const get = (type) => parts.find(p => p.type === type)?.value;
return `${get('weekday')}, ${get('day')} ${get('month')} ${get('year')} ${get('hour')}:${get('minute')}:${get('second')} GMT+8`;
}
async function loadData() {
try {
const response = await fetch('/get_video');
@ -114,7 +120,7 @@
<td>${entry.id}</td>
<td>${entry.vehicle_id}</td>
<td>${entry.direction}</td>
<td>${formatter.format(entry.timestamp)}</td>
<td>${formatToMakassar(entry.timestamp)}</td>
<td>${entry.speed.toFixed(1)}</td>
`;
tbody.appendChild(row);