diff --git a/index.js b/index.js index 555c8a1..f931baf 100644 --- a/index.js +++ b/index.js @@ -13,17 +13,15 @@ app.get('/time.php', (req, res) => { const date = new Date(); const options = { timeZone: tz, hour12: false }; - // Always pad with "0" - const pad = n => n.toString().padStart(2, '0'); - + // No leading zeros here 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' })); + const month = date.toLocaleString('en-GB', { ...options, month: 'numeric' }); + const day = date.toLocaleString('en-GB', { ...options, day: 'numeric' }); + const hour = date.toLocaleString('en-GB', { ...options, hour: 'numeric', hourCycle: 'h23' }); + const minute = date.toLocaleString('en-GB', { ...options, minute: 'numeric' }); + const second = date.toLocaleString('en-GB', { ...options, second: 'numeric' }); - // Format: DDMMYYYYHHMMSS + // Concatenate directly: DDMMYYYYHHMMSS const timeString = `${day}${month}${year}${hour}${minute}${second}`; res.send(timeString); } catch (err) { @@ -32,6 +30,7 @@ app.get('/time.php', (req, res) => { }); + app.listen(port, () => { console.log(`Server is running on port ${port}`); }); \ No newline at end of file