Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
const d = new Date("2024-06-15"); d.setFullYear(2025); // Change year to 2025 d.setMonth(0); // Change to January d.setDate(1); // Change to 1st of month d.setHours(12, 0, 0, 0); // Set time to noon // Clone before modifying const original = new Date("2024-06-15"); const modified = new Date(original.getTime()); modified.setMonth(11); // December — original unchanged
Result
Open