Friday, October 10, 2025
HomeLanguagesPHP | IntlCalendar getLeastMaximum() Function

PHP | IntlCalendar getLeastMaximum() Function

The IntlCalendar::getLeastMaximum() function is an inbuilt function in PHP which is used to get the smallest local maximum for a field. The value should be smaller or equal to IntlCalendar::getActualMaxmimum() which is smaller or equal to IntlCalendar::getMaximum() return value.

Syntax:

  • Object oriented style
    int IntlCalendar::getLeastMaximum( int $field )
  • Procedural style
    int intlcal_get_least_maximum( IntlCalendar $cal, int $field )

Parameters: This function uses two parameters as mentioned above and described below:

  • $cal: This parameter holds the resource of IntlCalendar.
  • $field: This parameter holds one of the IntlCalendar date/time field constants. The value of field constants are integer and lies between 0 to IntlCalendar::FIELD_COUNT.

Return Value: This function returns an integer value which represents a field value in the field unit on success or FALSE on failure.

Below program illustrates the IntlCalendar::getLeastMaximum() function in PHP:

Program:




<?php
  
// Set the date timezone
ini_set('date.timezone', 'Asia/Calcutta');
ini_set('intl.default_locale', 'en_US');
  
// Create a DateTime object
$calendar = IntlCalendar::fromDateTime('2019-03-21 09:19:29');
  
var_dump(
    $calendar->getLeastMaximum(IntlCalendar::FIELD_DAY_OF_MONTH),
    $calendar->getActualMaximum(IntlCalendar::FIELD_DAY_OF_MONTH),
    $calendar->getMaximum(IntlCalendar::FIELD_DAY_OF_MONTH), 
    $calendar->getLeastMaximum(IntlCalendar::FIELD_WEEK_OF_YEAR),
    $calendar->getActualMaximum(IntlCalendar::FIELD_WEEK_OF_YEAR),
    $calendar->getMaximum(IntlCalendar::FIELD_WEEK_OF_YEAR)
);
?>


Output:

int(28)
int(31)
int(31)
int(52)
int(52)
int(53)

Reference: https://www.php.net/manual/en/intlcalendar.getleastmaximum.php

RELATED ARTICLES

Most Popular

Dominic
32350 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6718 POSTS0 COMMENTS
Nicole Veronica
11880 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6838 POSTS0 COMMENTS
Ted Musemwa
7101 POSTS0 COMMENTS
Thapelo Manthata
6794 POSTS0 COMMENTS
Umr Jansen
6794 POSTS0 COMMENTS