SyntaxStudy
Sign Up
JavaScript Intermediate 4 min read

Date Setter Methods

Date Setters

Date setters modify components in place and return the new timestamp. Dates are mutable — clone before modifying if you need to preserve the original.

Example
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
Pro Tip

Dates are mutable objects in JavaScript — always clone with new Date(original.getTime()) before modifying.