Malagasy Intl
Dates
Write Gregorian dates in Malagasy and get the Malagasy names of months and weekdays, in five styles.
At a glance
Section titled “At a glance”formatDate('2026-11-23')23 Novambra 2026formatDate('2026-11-23', 'full')Alatsinainy 23 Novambra 2026
spellTime('07:15')amin'ny fito ora sy dimy ambin'ny folo minitra marainaspellTime('14:30')amin'ny roa ora sy telopolo minitra tolakandrospellTime('21:00')amin'ny sivy ora alina
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 |
parseDate(text, style) | Malagasy date text → date, or throws |
safeParseDate(text, style) | Text → date or error code, never throws |
tryParseDate(text, style) | Text → date, or nothing, never throws |
spellTime(time) | Time → Malagasy words |
parseTime(text) | Words → time, or throws |
safeParseTime(text) | Words → time or error code, never throws |
tryParseTime(text) | Words → time, or nothing, never throws |
spellDateTime(dateTime, style) | Date and time → date, then time in words |
parseDateTime(text, style) | Date and time in words → fields (rule 12) |
monthName(month, width) | 1–12 → month name, wide or abbreviated |
weekdayName(isoWeekday, width) | ISO weekday 1–7 → name, wide or abbreviated |
MalagasyDate::fromString($date)->format($style) | Date → text in a DateStyle |
MalagasyDate::parse($text, $style) | Malagasy date text → date, or throws |
MalagasyDate::safeParse($text, $style) | Text → date or error code, never throws |
MalagasyDate::tryParse($text, $style) → null | Text → date, or nothing, never throws |
MalagasyTime::fromString($time)->spell() | Time → Malagasy words |
MalagasyTime::parse($text) | Words → time, or throws |
MalagasyTime::safeParse($text) | Words → time or error code, never throws |
MalagasyTime::tryParse($text) → null | Words → time, or nothing, never throws |
MalagasyDateTime::fromString($dt)->spell($style) | Date and time → date, then time in words |
MalagasyDateTime::parse($text, $style) | Date and time in words → fields (rule 12) |
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”Alatsinainy 23 Novambra 2026
- Alatsinainyweekday (EEEE)
- 23day (d)
- Novambramonth (MMMM)
- 2026year (y)
| Case | Call | Result |
|---|---|---|
| long | formatDate('2026-11-23', 'long') | 23 Novambra 2026 |
| full | formatDate('2026-11-23', 'full') | Alatsinainy 23 Novambra 2026 |
| medium | formatDate('2026-11-23', 'medium') | 2026 Nov 23 |
| short | formatDate('2026-11-23', 'short') | 2026-11-23 |
| numeric | formatDate('2026-11-23', 'numeric') | 23/11/2026 |
import { formatDate } from '@mdgascar/date-time';
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\MalagasyIntl\DateTime\DateStyle;use Mdgascar\MalagasyIntl\DateTime\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);Reading a date
Section titled “Reading a date”parseDate reads back every style formatDate writes. Case and extra spaces do not matter, and day and month may have one digit.
Result
{ year: 2026, month: 11, day: 23 }
JSparseDate('23 Novambra 2026')PHPMalagasyDate::parse('23 Novambra 2026')import { parseDate } from '@mdgascar/date-time';
parseDate('23 Novambra 2026'); // { year: 2026, month: 11, day: 23 }parseDate('23/11/2026'); // { year: 2026, month: 11, day: 23 }MalagasyDate::parse('23 Novambra 2026')->month; // 11MalagasyDate::parse('23/11/2026')->day; // 23Saying the time
Section titled “Saying the time”spellTime says a time of day in Malagasy: the hour on a 12-hour clock and ora (hour), then sy and the minutes counted with minitra, then the part of the day (alina 0–3 and 20–23, maraina 4–11, atoandro 12, tolakandro 13–17, hariva 18–19). parseTime reads it back.
| Part of the day | Hours | Example |
|---|---|---|
| alina | 00:00 – 03:59 | amin'ny roa ambin'ny folo ora alina |
| maraina | 04:00 – 11:59 | amin'ny efatra ora maraina |
| atoandro | 12:00 | amin'ny roa ambin'ny folo ora atoandro |
| tolakandro | 13:00 – 17:59 | amin'ny iray ora tolakandro |
| hariva | 18:00 – 19:59 | amin'ny enina ora hariva |
| alina | 20:00 – 23:59 | amin'ny valo ora alina |
amin'ny roa ora sy telopolo minitra tolakandro
- amin'nyat
- roahour on a 12-hour clock
- orahour
- sy telopoloand 30
- minitraminutes
- tolakandropart of the day
Result
amin'ny roa ora sy telopolo minitra tolakandro
JSspellTime('14:30')PHPMalagasyTime::fromString('14:30')->spell()import { parseTime, spellTime } from '@mdgascar/date-time';
spellTime('07:15'); // "amin'ny fito ora sy dimy ambin'ny folo minitra maraina"spellTime('14:30'); // "amin'ny roa ora sy telopolo minitra tolakandro"spellTime('17:45'); // "amin'ny dimy ora sy dimy amby efapolo minitra tolakandro"parseTime("amin'ny roa ora sy telopolo minitra tolakandro"); // { hour: 14, minute: 30 }use Mdgascar\MalagasyIntl\DateTime\MalagasyTime;
MalagasyTime::fromString('07:15')->spell(); // "amin'ny fito ora sy dimy ambin'ny folo minitra maraina"MalagasyTime::fromString('14:30')->spell(); // "amin'ny roa ora sy telopolo minitra tolakandro"MalagasyTime::parse("amin'ny roa ora sy telopolo minitra tolakandro")->hour; // 14Date and time
Section titled “Date and time”spellDateTime writes the date in a date style, then the time in words.
Result
23 Novambra 2026 amin'ny roa ora sy telopolo minitra tolakandro
JSspellDateTime('2026-11-23T14:30')PHPMalagasyDateTime::fromString('2026-11-23T14:30')->spell()import { spellDateTime } from '@mdgascar/date-time';
spellDateTime('2026-11-23T14:30'); // "23 Novambra 2026 amin'ny roa ora sy telopolo minitra tolakandro"spellDateTime('2026-11-23T14:30', 'full'); // "Alatsinainy 23 Novambra 2026 amin'ny roa ora sy telopolo minitra tolakandro"use Mdgascar\MalagasyIntl\DateTime\DateStyle;use Mdgascar\MalagasyIntl\DateTime\MalagasyDateTime;
MalagasyDateTime::fromString('2026-11-23T14:30')->spell(); // "23 Novambra 2026 amin'ny roa ora sy telopolo minitra tolakandro"MalagasyDateTime::fromDateTime(new DateTimeImmutable())->spell(DateStyle::Full);Month and weekday names
Section titled “Month and weekday names”Weekdays use ISO numbers: Monday is 1, Sunday is 7.
import { monthName, weekdayName } from '@mdgascar/date-time';
monthName(6); // 'Jona'monthName(6, 'abbreviated'); // 'Jon'weekdayName(1); // 'Alatsinainy'weekdayName(7, 'abbreviated'); // 'Alah'use Mdgascar\MalagasyIntl\DateTime\MalagasyDate;use Mdgascar\MalagasyIntl\DateTime\NameWidth;
MalagasyDate::monthName(6); // 'Jona'MalagasyDate::monthName(6, NameWidth::Abbreviated); // 'Jon'MalagasyDate::weekdayName(1); // 'Alatsinainy'MalagasyDate::weekdayName(7, NameWidth::Abbreviated); // 'Alah'Input from databases and APIs
Section titled “Input from databases and APIs”You do not need to clean values before calling the library. Dates and times as databases and APIs write them are read directly:
- a time after a date is ignored by
formatDate(2026-11-23 14:30:45); - a month or day with one digit (
2026-1-5) is read; - seconds are dropped, never rounded:
14:30:59is said as 14:30; 9h30and14hwork like09:30and14:00;- numeric dates may use
-or.as well as/(23-11-2026,23.11.2026).
| Case | Call | Result |
|---|---|---|
| one-digit month and day | formatDate('2026-1-5') | 5 Janoary 2026 |
| a time after the date | formatDate('2026-11-23 14:30:45') | 23 Novambra 2026 |
| a time zone (UTC) | formatDate('2026-11-23T14:30:00Z') | 23 Novambra 2026 |
| a time zone that changes the day | formatDate('2026-11-23T22:30:00Z') | 24 Novambra 2026 |
| Case | Call | Result |
|---|---|---|
| hours and minutes | spellTime('14:30') | amin'ny roa ora sy telopolo minitra tolakandro |
| with seconds | spellTime('14:30:45') | amin'ny roa ora sy telopolo minitra tolakandro |
| with an h | spellTime('9h30') | amin'ny sivy ora sy telopolo minitra maraina |
| with a time zone | spellTime('14:30Z') | amin'ny dimy ora sy telopolo minitra tolakandro |
Time zones
Section titled “Time zones”Text with a time zone (Z, +03:00, -05:00) is an instant, and it is read in Madagascar time: UTC+3 all year, with no daylight saving. So a value from new Date().toISOString() needs no conversion, and the day can change: 2026-11-23T22:30:00Z is already 24 November, 01:30, in Madagascar. A Date or DateTime object is read in its own local fields, as before.
Reading a date and time back
Section titled “Reading a date and time back”Result
{ year: 2026, month: 11, day: 23, hour: 14, minute: 30 }
JSparseDateTime('23 Novambra 2026 amin\'ny roa ora sy telopolo minitra tolakandro')PHPMalagasyDateTime::parse('23 Novambra 2026 amin\'ny roa ora sy telopolo minitra tolakandro')parseDateTime reads what spellDateTime writes: a date in any style, then amin'ny and the time in words. safeParseDateTime and tryParseDateTime do not throw.
import { parseDateTime } from '@mdgascar/date-time';
parseDateTime("23 Novambra 2026 amin'ny roa ora sy telopolo minitra tolakandro");// { year: 2026, month: 11, day: 23, hour: 14, minute: 30 }$value = MalagasyDateTime::parse("23 Novambra 2026 amin'ny roa ora sy telopolo minitra tolakandro");$value->date->day; // 23$value->time->hour; // 14Unix milliseconds and PHP dates
Section titled “Unix milliseconds and PHP dates”formatDate, spellTime and spellDateTime also take Unix milliseconds, such as Date.now(), read in Madagascar time. A number is read as milliseconds only between 2001 and 2200; any other number is INVALID_TYPE, because it is probably seconds. In PHP, use fromMilliseconds() or fromDateTime().
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 |