Modules
Dates
Write Gregorian dates in Malagasy and get the Malagasy names of months and weekdays, in five styles.
Try it
Section titled “Try it”Result
Alahady 26 Jona 1960
JSformatDate('1960-06-26', 'full')PHPMalagasyDate::fromString('1960-06-26')->format(DateStyle::Full)Quick reference
Section titled “Quick reference”formatDate(date, style) | Date → text in a DateStyle |
getMonthName(month, width) | 1–12 → month name, wide or abbreviated |
getWeekdayName(isoWeekday, width) | ISO weekday 1–7 → name, wide or abbreviated |
MalagasyDate::fromString($date)->format($style) | Date → text in a DateStyle |
MalagasyDate::monthName($month, $width) | 1–12 → month name, wide or abbreviated |
MalagasyDate::weekdayName($weekday, $width) | ISO weekday 1–7 → name, wide or abbreviated |
Formatting a date
Section titled “Formatting a date”| Style | Output for 2026-11-23 |
|---|---|
long |
23 Novambra 2026 (default) |
full |
Alatsinainy 23 Novambra 2026 |
medium |
2026 Nov 23 |
short |
2026-11-23 |
numeric |
23/11/2026 |
import { formatDate } from '@mdgascar/date';
formatDate('2026-11-23'); // '23 Novambra 2026'formatDate('2026-11-23', 'full'); // 'Alatsinainy 23 Novambra 2026'formatDate({ year: 1960, month: 6, day: 26 }, 'full'); // 'Alahady 26 Jona 1960'formatDate(new Date(), 'numeric');use Mdgascar\MdgUtils\Date\DateStyle;use Mdgascar\MdgUtils\Date\MalagasyDate;
MalagasyDate::fromString('2026-11-23')->format(); // '23 Novambra 2026'MalagasyDate::fromString('2026-11-23')->format(DateStyle::Full); // 'Alatsinainy 23 Novambra 2026'MalagasyDate::fromParts(1960, 6, 26)->format(DateStyle::Full); // 'Alahady 26 Jona 1960'MalagasyDate::fromDateTime(new DateTimeImmutable())->format(DateStyle::Numeric);Month and weekday names
Section titled “Month and weekday names”Weekdays use ISO numbers: Monday is 1, Sunday is 7.
import { getMonthName, getWeekdayName } from '@mdgascar/date';
getMonthName(6); // 'Jona'getMonthName(6, 'abbreviated'); // 'Jon'getWeekdayName(1); // 'Alatsinainy'getWeekdayName(7, 'abbreviated'); // 'Alah'use Mdgascar\MdgUtils\Date\MalagasyDate;use Mdgascar\MdgUtils\Date\NameWidth;
MalagasyDate::monthName(6); // 'Jona'MalagasyDate::monthName(6, NameWidth::Abbreviated); // 'Jon'MalagasyDate::weekdayName(1); // 'Alatsinainy'MalagasyDate::weekdayName(7, NameWidth::Abbreviated); // 'Alah'Errors
Section titled “Errors”| Input | Error code |
|---|---|
A date that is not a string, Date or { year, month, day }; a month or weekday that is not a whole number |
INVALID_TYPE |
Not a real calendar date (2026-02-30) |
INVALID_FORMAT |
| Month outside 1–12, weekday outside 1–7 | OUT_OF_RANGE |
Rules and sources
Section titled “Rules and sources”Malagasy dates: rules and sourcesMonth and weekday names, the five styles and recorded decisions.