eZPublishCommunityProject(LegacyStack)  2013.5
eZDate Class Reference

Locale aware date handler. More...

Public Member Functions

 adjustDate ($month, $day=0, $year=0)
 attribute ($name)
 attributes ()
 day ()
 duplicate ()
 eZDate ($date=false)
 hasAttribute ($name)
 isEqualTo ($date)
 isGreaterThan ($date, $equal=false)
 isValid ()
 locale ()
 month ()
 setDay ($day)
 setLocale ($locale)
 setMDY ($month, $day=0, $year=0)
 setMonth ($month)
 setTimeStamp ($stamp)
 setYear ($year)
 timeStamp ()
 toString ($short=false)
 year ()

Static Public Member Functions

static create ($month, $day=0, $year=0)

Public Attributes

 The current date as a timestamp without hour, minute or second values. More...
 Locale object, is just a reference to minimize memory usage. More...

Detailed Description

Locale aware date handler.

eZDate handles date values in months, days and years. The time stored as a timestamp with 0 hours, 0 minutes and 0 seconds.

A new instance of eZDate will automaticly use the current locale and current date, if you however want a different locale use the setLocale() function. The current locale can be fetched with locale().

Change the date directly with setYear(), setMonth(), setDay() and setMDY(). You can also adjust the date relative to it's current value by using adjustDate(). Use timeStamp() to get the current timestamp value or year(), month() and day() for the respective values.

When creating new times you're advised to use the static create() function which returns a new eZDate object. You can also create a copy with the duplicate() function.

Date checking is done with the isGreaterThan() and isEqualTo() functions.

Text output is done with toString() which can return a long string (default) or short string representation according to the current locale.


$us_locale = eZLocale::instance( 'us' );
$date1 = new eZDate();
$date2 = eZDate::create();
$date2->setLocale( $us_locale );
$date2->adjustDate( 1, 2, 3 );
$date3 = $date1->duplicate();
print( $date1->toString() );
print( $date2->toString( true ) );
print( $date1->isEqualTo( $date3 ) ? 'true' : 'false' ); // Prints 'true'
See Also
eZTime, eZDateTime, eZLocale

Member Function Documentation

eZDate::adjustDate (   $month,
  $day = 0,
  $year = 0 

Adjusts the date relative to it's current value. This is useful for adding/subtracting years, months or days to an existing date.

eZDate::attribute (   $name)
eZDate::attributes ( )

Referenced by hasAttribute().

static eZDate::create (   $month,
  $day = 0,
  $year = 0 

Creates a new eZDate object with the date values $month, $day and $year and returns a reference to it. Any value can be ommitted or set to 0 to use the current date value.

eZDate::day ( )

Returns the day element.

Referenced by attribute().

eZDate::duplicate ( )
This function is deprecated in PHP5, use the PHP5 clone keyword instead Creates an exact copy of this object and returns it.
eZDate::eZDate (   $date = false)

Creates a new date object with default locale, if $date is not supplied the current date is used.

Referenced by create().

eZDate::hasAttribute (   $name)
eZDate::isEqualTo (   $date)

Returns true if this object is equal to $date. $date can be specified as a timestamp value or as an eZDate object.

eZDate::isGreaterThan (   $date,
  $equal = false 

Returns true if this object has a date greater than $date. $date can be specified as a timestamp value or as an eZDate object. If $equal is true it returns true if they are equal as well.

eZDate::isValid ( )
true if the date has valid data.

Referenced by attribute().

eZDate::locale ( )

Returns the current locale.

eZDate::month ( )

Returns the month element.

Referenced by attribute().

eZDate::setDay (   $day)

Sets the day leaving the other elements untouched.

eZDate::setLocale (   $locale)

Sets the locale to $locale which is used in text output.

eZDate::setMDY (   $month,
  $day = 0,
  $year = 0 

Sets the year, month and day elements. If $day or $year is omitted or set 0 they will get a value taken from the current time.

eZDate::setMonth (   $month)

Sets the month leaving the other elements untouched.

eZDate::setTimeStamp (   $stamp)
eZDate::setYear (   $year)

Sets the year leaving the other elements untouched.

eZDate::timeStamp ( )

Returns the timestamp value, this is the number of seconds since the epoch with hours, minutes and seconds set to 0.

The value is returned as a reference and should not be modified.

Referenced by attribute(), isEqualTo(), and isGreaterThan().

eZDate::toString (   $short = false)

Creates a string representation of the date using the current locale and returns it. If $short is true a short representation is used.

eZDate::year ( )

Returns the year element.

Referenced by attribute().

Member Data Documentation


The current date as a timestamp without hour, minute or second values.

Referenced by timeStamp().


Referenced by isValid().


Locale object, is just a reference to minimize memory usage.

Referenced by locale().

The documentation for this class was generated from the following file: