Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
eZDate Class Reference
Locale system

Locale aware date handler. More...

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

## Static Public Member Functions
static | create ( $month, $day=0, $year=0)

## Public Attributes
| $Locale
| Locale object, is just a reference to minimize memory usage. More...
| $Date
| The current date as a timestamp without hour, minute or second values. More...
| $IsValid

## 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:

$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'
eZDate
Locale aware date handler.
Definition: ezdate.php:58
eZDate\create
static create( $month, $day=0, $year=0)
Definition: ezdate.php:274
eZLocale\instance
static instance( $localeString=false)
Definition: ezlocale.php:1536

See also
  eZTime, eZDateTime, eZLocale

Definition at line 57 of file ezdate.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZDate::__construct | ( |  | $date = `false` | ) |

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

Parameters

  int | bool | $date |

Definition at line 63 of file ezdate.php.

References eZLocale\instance().

## Member Function Documentation

## ◆ adjustDate()

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 220 of file ezdate.php.

## ◆ attribute()

eZDate::attribute | ( |  | $name | ) |

Definition at line 93 of file ezdate.php.

References day(), isValid(), month(), timeStamp(), eZDebug\writeError(), and year().

## ◆ attributes()

eZDate::attributes | ( |  | ) |

Definition at line 79 of file ezdate.php.

Referenced by hasAttribute().

## ◆ create()

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

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 274 of file ezdate.php.

## ◆ day()

eZDate::day | ( |  | ) |

Returns the day element.

Definition at line 196 of file ezdate.php.

Referenced by attribute().

## ◆ duplicate()

eZDate::duplicate | ( |  | ) |

Deprecated:
  This function is deprecated in PHP5, use the PHP5 clone keyword instead Creates an exact copy of this object and returns it.

Definition at line 290 of file ezdate.php.

## ◆ hasAttribute()

eZDate::hasAttribute | ( |  | $name | ) |

Definition at line 88 of file ezdate.php.

References attributes().

## ◆ isEqualTo()

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 255 of file ezdate.php.

References timeStamp().

## ◆ isGreaterThan()

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 232 of file ezdate.php.

References timeStamp().

## ◆ isValid()

eZDate::isValid | ( |  | ) |

Returns
  true if the date has valid data.

Definition at line 113 of file ezdate.php.

References $IsValid.

Referenced by attribute().

## ◆ locale()

eZDate::locale | ( |  | ) |

Returns the current locale.

Definition at line 129 of file ezdate.php.

References $Locale.

## ◆ month()

eZDate::month | ( |  | ) |

Returns the month element.

Definition at line 188 of file ezdate.php.

Referenced by attribute().

## ◆ setDay()

eZDate::setDay | ( |  | $day | ) |

Sets the day leaving the other elements untouched.

Definition at line 171 of file ezdate.php.

## ◆ setLocale()

eZDate::setLocale | ( |  | $locale | ) |

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

Definition at line 121 of file ezdate.php.

## ◆ setMDY()

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 205 of file ezdate.php.

## ◆ setMonth()

eZDate::setMonth | ( |  | $month | ) |

Sets the month leaving the other elements untouched.

Definition at line 162 of file ezdate.php.

## ◆ setTimeStamp()

eZDate::setTimeStamp | ( |  | $stamp | ) |

Definition at line 144 of file ezdate.php.

## ◆ setYear()

eZDate::setYear | ( |  | $year | ) |

Sets the year leaving the other elements untouched.

Definition at line 153 of file ezdate.php.

## ◆ timeStamp()

eZDate::timeStamp | ( |  | ) |

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 139 of file ezdate.php.

References $Date.

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

## ◆ toString()

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 300 of file ezdate.php.

## ◆ year()

eZDate::year | ( |  | ) |

Returns the year element.

Definition at line 180 of file ezdate.php.

Referenced by attribute().

## Member Data Documentation

## ◆ $Date

eZDate::$Date

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

Definition at line 313 of file ezdate.php.

Referenced by timeStamp().

## ◆ $IsValid

eZDate::$IsValid

Definition at line 314 of file ezdate.php.

Referenced by isValid().

## ◆ $Locale

eZDate::$Locale

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

Definition at line 311 of file ezdate.php.

Referenced by locale().

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

- ezdate.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.