From 27755fec3634c11f8a33c24bf6db52a6e827e2af Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Wed, 20 Aug 2025 23:10:24 -0600 Subject: [PATCH] Fix time? --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index d83245e..555c8a1 100644 --- a/index.js +++ b/index.js @@ -12,13 +12,18 @@ app.get('/time.php', (req, res) => { try { const date = new Date(); const options = { timeZone: tz, hour12: false }; - const pad = n => n.toString().padStart(2, ' '); + + // Always pad with "0" + const pad = n => n.toString().padStart(2, '0'); + const year = date.toLocaleString('en-GB', { ...options, year: 'numeric' }); const month = pad(date.toLocaleString('en-GB', { ...options, month: '2-digit' })); const day = pad(date.toLocaleString('en-GB', { ...options, day: '2-digit' })); const hour = pad(date.toLocaleString('en-GB', { ...options, hour: '2-digit', hourCycle: 'h23' })); const minute = pad(date.toLocaleString('en-GB', { ...options, minute: '2-digit' })); const second = pad(date.toLocaleString('en-GB', { ...options, second: '2-digit' })); + + // Format: DDMMYYYYHHMMSS const timeString = `${day}${month}${year}${hour}${minute}${second}`; res.send(timeString); } catch (err) { @@ -26,6 +31,7 @@ app.get('/time.php', (req, res) => { } }); + app.listen(port, () => { console.log(`Server is running on port ${port}`); }); \ No newline at end of file