SvelteDate class provides a reactive wrapper around JavaScript’s Date object. When you call methods that modify the date, Svelte’s reactivity system is automatically notified.
Import
Usage
Basic usage
Clock example
Notes
- All mutating methods trigger reactivity (setDate, setHours, etc.)
- Reading methods work like normal Date (getDate, getHours, etc.)
- Inherits all methods from the standard Date object
- More efficient than using
$state()with a Date object