Time zones and server listen host

This commit is contained in:
Will Bradley 2025-07-16 13:27:50 -07:00
parent 275c91f4e1
commit 2b8450951e
2 changed files with 8 additions and 4 deletions

View File

@ -365,9 +365,11 @@
function formatTimeAgo(dateString) { function formatTimeAgo(dateString) {
if (!dateString) return 'Never'; if (!dateString) return 'Never';
const date = new Date(dateString); // Parse UTC timestamp correctly
const date = new Date(dateString + (dateString.includes('Z') ? '' : 'Z'));
const now = new Date(); const now = new Date();
const diffInSeconds = Math.floor((now - date) / 1000); const diffInSeconds = Math.floor((now - date) / 1000);
console.log(date,now,diffInSeconds);
if (diffInSeconds < 60) { if (diffInSeconds < 60) {
return 'Just now'; return 'Just now';
@ -389,7 +391,8 @@
function formatTimeUntil(dateString) { function formatTimeUntil(dateString) {
if (!dateString) return 'Unknown'; if (!dateString) return 'Unknown';
const date = new Date(dateString); // Parse UTC timestamp correctly
const date = new Date(dateString + (dateString.includes('Z') ? '' : 'Z'));
const now = new Date(); const now = new Date();
const diffInSeconds = Math.floor((date - now) / 1000); const diffInSeconds = Math.floor((date - now) / 1000);

View File

@ -12,6 +12,7 @@ const path = require('path');
require('dotenv').config(); require('dotenv').config();
const app = express(); const app = express();
const HOST = process.env.HOST || "0.0.0.0";
const PORT = process.env.PORT || 3000; const PORT = process.env.PORT || 3000;
// Database setup // Database setup
@ -453,6 +454,6 @@ app.get('/login', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'login.html')); res.sendFile(path.join(__dirname, 'public', 'login.html'));
}); });
app.listen(PORT, () => { app.listen(PORT, HOST, () => {
console.log(`Server running on port ${PORT}`); console.log(`Server running on http://${HOST}:${PORT}`);
}); });