downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

DateInterval::__construct> <DateTimeZone::listIdentifiers
Last updated: Fri, 24 Sep 2010

view this page in

The DateInterval class

Introduction

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.

Class synopsis

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

Properties

y

Number of years.

m

Number of months.

d

Number of days.

h

Number of hours.

i

Number of minutes.

s

Number of seconds.

invert

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

days

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

Table of Contents



add a note add a note User Contributed Notes
DateInterval
jeff dot davies at yahoo dot com
15-Sep-2010 02: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-Aug-2010 05: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.

DateInterval::__construct> <DateTimeZone::listIdentifiers
Last updated: Fri, 24 Sep 2010
 
 
show source | credits | sitemap | contact | advertising | mirror sites