JavaScript Date_calc Guide
Date arithmetic: adding/subtracting time, calculating differences, and comparing dates in JavaScript. The guide walks through Date Calculations. Add days: `new Date(date.getTime() + days * 86400000)`. Diff ms: `date2 - date1`. Diff days: `Math.floor((d2 - d1) / 86400000)`. Set: `date.setFullYear(y)`, `date.setMonth(m)`, `date.setDate(d)`, `date.setHours(h)`. Clone: `new Date(date)`. Compare: `date1.getTime() === date2.getTime()`. Better: use a library like date-fns for complex date math. The guide is organized into 1 sections that build on each other, each pairing a prose explanation with runnable code. Related guides: Arrays, Strings, Numbers, Math, Date. This is one of 145 JavaScript guides on JS Reference — see the full list on the guides page. Practice what you learn in the JavaScript playground, and look up any unfamiliar term in the JavaScript glossary.