API reference
startOfMonth
API index · Input types and conventions · Installation
startOfMonth(value) → same kind
Find the first date of the containing month. PlainYearMonth is not accepted because it already represents a whole month.
import { startOfMonth } from '@frantss/temporal-fns';
startOfMonth(Temporal.PlainDate.from('2024-02-29')).toString(); // => '2024-02-01'
startOfMonth(Temporal.PlainDateTime.from('2026-10-23T14:30')).toString(); // => '2026-10-01T00:00:00'
startOfMonth(Temporal.PlainDate.from('-271821-04-19')); // throws RangeErrorRelated: endOfMonth, eachMonthOfInterval, isSameMonth.
Behaviors: BND-001: Plain date boundaries return complete dates; BND-002: Plain date-time boundaries retain nanosecond endpoint precision; BND-013: Unavailable required boundaries are rejected rather than clipped.