Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save khrystynaserediak-rgb/f6cb87e6ae080cabe49626c49b55fc86 to your computer and use it in GitHub Desktop.

Select an option

Save khrystynaserediak-rgb/f6cb87e6ae080cabe49626c49b55fc86 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Date Spoofing Test</title>
</head>
<body>
<h2>Date Spoofing Test</h2>
<pre id="output"></pre>
<script>
const log = (label, value) => {
const line = `${label}: ${value}`;
console.log(line);
document.getElementById('output').textContent += line + '\n';
};
// This is what a page script sees when using new Date()
const d = new Date();
log('Date.name', Date.name);
log('new Date() [page sees]', d);
log('new Date().toString()', d.toString());
log('new Date().getHours()', d.getHours());
log('new Date().getDate()', d.getDate());
log('new Date().getTimezoneOffset()', d.getTimezoneOffset());
log('new Date().toLocaleString()', d.toLocaleString());
log('new Date().toISOString()', d.toISOString());
log('Intl timezone', Intl.DateTimeFormat().resolvedOptions().timeZone);
log('', '');
log('--- Proof: template literal uses toString() ---', '');
log(`\`${d}\``, `${d}`);
log('', '');
log('--- March 31 ---', '');
const m31 = new Date('2026-03-31');
log("new Date('2026-03-31').toString()", m31.toString());
log("new Date('2026-03-31').getDate()", m31.getDate());
log('', '');
log('--- March 13 ---', '');
const m13 = new Date('2026-03-13');
log("new Date('2026-03-13').toString()", m13.toString());
log("new Date('2026-03-13').getDate()", m13.getDate());
log('', '');
log('--- May 10 ---', '');
const may10 = new Date('2026-05-10');
log("new Date('2026-05-10').toString()", may10.toString());
log("new Date('2026-05-10').getDate()", may10.getDate());
log('', '');
log('--- Multi-arg constructor ---', '');
const mc = new Date(2026,2,31);
log('new Date(2026,2,31).toString()', mc.toString());
log('new Date(2026,2,31).getDate()', mc.getDate());
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment