Skip to content

Novis\Intl\DateFormat

Writes dates and times the way a language and region write them. Each method takes a whole list and a locale tag, such as "de" or "en-GB", and formats the whole list in one call.

Members

3 members.

MemberSignature
dateTimesdateTimes(array<Core\Time\DateTime> $values, string $locale, ?{ length?: Length, fields?: Fields, seconds?: bool, zone?: ZoneStyle } $options = null): array<string>
datesdates(array<Core\Time\Date> $values, string $locale, ?{ length?: Length, fields?: Fields } $options = null): array<string>
timestimes(array<Core\Time\TimeOfDay> $values, string $locale, ?{ seconds?: bool } $options = null): array<string>

Enums

  • Length { Short, Medium, Long }How long a formatted date is. For March 1, 2026 in English for the United States, Short writes "3/1/26". Medium writes "Mar 1, 2026". This is the default. Long writes "March 1, 2026". Long is the longest length. To also show the day of the week, set fields to Fields::YearMonthDayWeekday.
  • Fields { Day, MonthDay, YearMonthDay, Weekday, DayWeekday, MonthDayWeekday, YearMonthDayWeekday, Month, YearMonth, Year }Which parts of a date DateFormat::dates and DateFormat::dateTimes show. Each case is named after the parts it shows. The locale decides the order of the parts. A locale is a language and region, such as en-US or de for German. These examples use Length::Long and en-US. Day shows the day of the month, such as "5". MonthDay shows the month and the day, such as "January 5". YearMonthDay shows the year, the month and the day, such as "January 5, 2026". This is the default. Weekday shows the day of the week, such as "Monday". DayWeekday shows the day of the month and the day of the week, such as "5 Monday". MonthDayWeekday shows the month, the day and the day of the week, such as "Monday, January 5". YearMonthDayWeekday shows all four parts, such as "Monday, January 5, 2026". Month shows the month, such as "January". YearMonth shows the month and the year, such as "January 2026". In de, this is "Januar 2026". Year shows the year, such as "2026". Month, YearMonth and Year have no day. A time of day needs a day, so DateFormat::dateTimes throws a LogicError for these three cases.
  • ZoneStyle { None, Offset, Location, Generic }How DateFormat::dateTimes shows the time zone of a date and time. None shows no time zone. This is the default. Offset shows the difference from UTC, such as "GMT+2". Location shows the country or city of the zone. For the zone Europe/Vienna, this is "Austria Time". Generic shows the general name of the zone, such as "Central European Time". It does not say whether it is summer time, so the name is the same in summer and in winter.