Locale aware date handler.
More...
List of all members.
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.
Example: include_once( 'lib/ezlocale/classes/ezlocale.php' );
include_once( 'lib/ezlocale/classes/ezdate.php' );
$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' );
- See also:
-
eZLocale
Definition at line ezdate.php.
Constructor & Destructor Documentation
eZDate::eZDate |
( |
$ |
date = false |
) |
|
|
|
Creates a new date object with default locale, if $date is not supplied the current date is used.
Definition at line ezdate.php.
References year().
Referenced by duplicate(). |
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.
Definition at line ezdate.php.
References year(). |
& 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.
Definition at line ezdate.php.
References year(). |
|
Creates an exact copy of this object and returns a reference to it.
Definition at line ezdate.php.
References eZDate(). |
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.
Definition at line ezdate.php.
References year(). |
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.
Definition at line ezdate.php.
References year(). |
|
- Returns:
-
true if the date has valid data.
Definition at line ezdate.php. |
|
Sets the day leaving the other elements untouched.
Definition at line ezdate.php.
References year(). |
eZDate::setLocale |
( |
&$ |
locale |
) |
|
|
|
Sets the locale to $locale which is used in text output.
Definition at line ezdate.php.
References locale(). |
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.
Definition at line ezdate.php.
References year(). |
eZDate::setMonth |
( |
$ |
month |
) |
|
|
|
Sets the month leaving the other elements untouched.
Definition at line ezdate.php.
References year(). |
eZDate::setYear |
( |
$ |
year |
) |
|
|
|
Sets the year leaving the other elements untouched.
Definition at line ezdate.php.
References year(). |
|
Returns the timestamp value, this is the number of seconds since the epoch with hours, minutes and seconds set to 0. - Note:
-
The value is returned as a reference and should not be modified.
Definition at line ezdate.php.
References Date.
Referenced by 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.
Definition at line ezdate.php.
References Locale. |
The documentation for this class was generated from the following file:
|