PHP Doku:: The DateInterval class - class.dateinterval.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatums- und zeitrelevante ErweiterungenDatum und UhrzeitThe DateInterval class

Ein Service von Reinhard Neidl - Webprogrammierung.

Datum und Uhrzeit




The DateInterval class


Representation of date interval. A date interval stores either a fixed amount of time (in years, months, days, hours etc) or a relative time string in the format that DateTime's constructor supports.


DateInterval {
/* Eigenschaften */
public integer $y ;
public integer $m ;
public integer $d ;
public integer $h ;
public integer $i ;
public integer $s ;
public integer $invert ;
public mixed $days ;
/* Methoden */
public __construct ( string $interval_spec )
public static DateInterval createFromDateString ( string $time )
public string format ( string $format )



Number of years.


Number of months.


Number of days.


Number of hours.


Number of minutes.


Number of seconds.


Is 1 if the interval is inverted and 0 otherwise. See DateInterval::format().


Total number of days the interval spans. If this is unknown, days will be FALSE.


2 BenutzerBeiträge:
- Beiträge aktualisieren...
jeff dot davies at yahoo dot com
15.09.2010 2:15
This class became available in PHP 5.3. It is not present in 5.2 or earlier releases. I found this out the hard way when you PHP scripts stopped working when I deployed them onto a Yahoo server. Yahoo has 5.2 while my machine hosts 5.3.
sebastien dot michea at manaty dot net
30.08.2010 5:25
It would be nice that when converting a DateInterval to a string, the interval specification used to construct the object is returned (like "P2W").
I need this to serialize a DateInterval object in order to store it in a postgres DB.

PHP Powered Diese Seite bei
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)