function getUserTimezone() { try { // Get the user's timezone const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; // Get UTC offset const offset = new Date().getTimezoneOffset(); const hours = Math.abs(Math.floor(offset / 60)); const minutes = Math.abs(offset % 60); const sign = offset <= 0 ? '+' : '-'; const utcOffset = 'UTC' + sign + hours.toString().padStart(2, '0') + ':' + minutes.toString().padStart(2, '0'); return timezone + ' (' + utcOffset + ')'; } catch (error) { // Fallback if timezone detection fails const offset = new Date().getTimezoneOffset(); const hours = Math.abs(Math.floor(offset / 60)); const minutes = Math.abs(offset % 60); const sign = offset <= 0 ? '+' : '-'; return 'UTC' + sign + hours.toString().padStart(2, '0') + ':' + minutes.toString().padStart(2, '0'); } } function getUtcTime(utcTime) { var ttt = utcTime; let dateStr = ''; let timeStr = ''; if(ttt.length > 0){ // Parse the UTC date string and convert to local timezone // Add 'Z' to explicitly mark as UTC time const utcDateTime = new Date(ttt + 'Z'); // Get local date in YYYY-MM-DD format const year = utcDateTime.getFullYear(); const month = String(utcDateTime.getMonth() + 1).padStart(2, '0'); const day = String(utcDateTime.getDate()).padStart(2, '0'); dateStr = year + '-' + month + '-' + day; // Get local time in HH:MM format const hours = String(utcDateTime.getHours()).padStart(2, '0'); const minutes = String(utcDateTime.getMinutes()).padStart(2, '0'); timeStr = hours + ':' + minutes; console.log('UTC time from DB:', ttt); console.log('Converted to local time:', dateStr + ' ' + timeStr); return dateStr + ' ' + timeStr; } return ''; }