PHP 5.6.14 is available


(PHP 5.5.0, PECL >= 3.0.0a1)

IntlCalendar::addAdd a (signed) amount of time to a field


Stil obiect-orientat

public bool IntlCalendar::add ( int $field , int $amount )

Stil procedural

bool intlcal_add ( IntlCalendar $cal , int $field , int $amount )

Add a signed amount to a field. Adding a positive amount allows advances in time, even if the numeric value of the field decreases (e.g. when working with years in BC dates).

Other fields may need to adjusted – for instance, adding a month to the 31st of January will result in the 28th (or 29th) of February. Contrary to IntlCalendar::roll(), when a value wraps around, more significant fields may change. For instance, adding a day to the 31st of January will result in the 1st of February, not the 1st of Janurary.



The IntlCalendar resource.


Una din constantele de câmp dată/oră ale IntlCalendar. Acestea sunt valori întregi de la 0 până la IntlCalendar::FIELD_COUNT.


The signed amount to add to the current field. If the amount is positive, the instant will be moved forward; if it is negative, the instant wil be moved into the past. The unit is implicit to the field type. For instance, hours for IntlCalendar::FIELD_HOUR_OF_DAY.

Valorile întoarse

Returns TRUE on success sau FALSE în cazul eșecului.


Example #1 IntlCalendar::add()


$cal = new IntlGregorianCalendar(2012/* January */31);
IntlDateFormatter::formatObject($cal), "\n";

IntlDateFormatter::formatObject($cal), "\n";

IntlDateFormatter::formatObject($cal), "\n";

Exemplul de mai sus va afișa:

31 janv. 2012 00:00:00
29 févr. 2012 00:00:00
1 mars 2012 00:00:00

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top