Fix timezone handling for accurate 48-hour expiry display
- Fixed getTimeAgo(), getTimeRemaining(), and getRemainingClass() functions - Database stores UTC timestamps but frontend was treating them as local time - Added logic to append 'Z' to timestamps without timezone info to force UTC interpretation - Now properly shows 48-hour countdown instead of incorrect 52-hour or 28-hour values - Affects both main app (app-mapbox.js) and admin panel (admin.js)
This commit is contained in:
parent
276dc65195
commit
58b6a13106
2 changed files with 8 additions and 4 deletions
|
@ -494,7 +494,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
|
||||
function getTimeAgo(timestamp) {
|
||||
const now = new Date();
|
||||
const reportTime = new Date(timestamp);
|
||||
// Ensure timestamp is treated as UTC if it doesn't have timezone info
|
||||
const reportTime = new Date(timestamp.includes('T') ? timestamp : timestamp + 'Z');
|
||||
const diffInMinutes = Math.floor((now - reportTime) / (1000 * 60));
|
||||
|
||||
if (diffInMinutes < 1) return 'just now';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue