monthDay()
monthDay(input, options?): MonthDay
monthDay(input, zone?): MonthDay
monthDay(month, day): MonthDayCreates a MonthDay from a month-first string, 1-indexed numbers, a fields object, or an existing date. February 29 is accepted so leap-day birthdays and anniversaries stay intact.
import { datetime, monthDay } from 'native-dates';
const fromIso = monthDay('10-17');
const fromSlash = monthDay('10/17');
const fromNumbers = monthDay(2, 29);
const fromFields = monthDay({ month: 10, day: 17 });
const fromInstant = monthDay(datetime('2026-10-18T02:00:00Z'), 'America/Los_Angeles');
fromNumbers.toString(); // '02-29'
fromInstant.toString(); // '10-17'Parameters
Month-first string, fields object, date or timestamp, or 1-indexed month from 1 to 12.
Time zone or options object, or whole day from 1 to 31 when passing two numbers.
4 options
Time zone used to read the month and day of an instant string, DateTime, or Date.
BCP 47 locale tag carried on the returned MonthDay and every value derived from it.
falseRead slash, dot, or single-digit dash strings day-first, matching dayMonth().
falseRead English or localized month names like '17 février' and return null on unreadable input with @native-dates/plugins/loose.
Returns
A MonthDay with no year, or null when loose mode cannot read input.
When the loose plugin is loaded, loose mode parses month names in English or the active locale and returns null on unreadable input:
import { monthDay } from 'native-dates';
import '@native-dates/plugins/loose';
monthDay('Oct 17', { loose: true })?.toString(); // '10-17'
monthDay('17 février', { loose: true, locale: 'fr' })?.toString(); // '02-17'
monthDay('whenever', { loose: true }); // null