diff --git a/index.js b/index.js
index 8630a77..f7271fa 100644
--- a/index.js
+++ b/index.js
@@ -83,27 +83,13 @@ app.get('/time.php', (req, res) => {
minute: '2-digit',
second: '2-digit'
});
-
- /*
- {
- ...options,
- year: 'numeric',
- month: '2-digit',
- day: '2-digit',
- hour: '2-digit',
- minute: '2-digit',
- second: '2-digit'
- } // Old format
- */
- // Example output with space-padded single digits instead of zero-padded
- const spacePad = n => n.toString().padStart(2, ' ');
const parts = formatter.formatToParts(date);
const get = type => parts.find(p => p.type === type).value;
- //const formatted = `${get('day')}${get('month')}${get('year')}${get('hour')}${get('minute')}${get('second')}`;
- const singleDigit = n => ' ' + (n.startsWith('0') ? n.slice(1) : n);
- const formatted = `${singleDigit(get('day'))}${singleDigit(get('month'))}${singleDigit(get('year'))}${singleDigit(get('hour'))}${singleDigit(get('minute'))}${singleDigit(get('second'))}`;
+ const formatted = `${get('day')}${get('month')}${get('year')}${get('hour')}${get('minute')}${get('second')}`;
const msg = fs.readFileSync(path.join(__dirname, 'msg.html'), 'utf8');
- res.send(`${formatted}
${msg}`);
+ // unix timestamp as const
+ const unixTimestamp = Math.floor(date.getTime() / 1000);
+ res.send(`${formatted}\n${unixTimestamp}
${msg}`);
} catch (e) {
res.status(400).send('Invalid timezone');
}