|
eZ Publish
[4.2]
|
Locale aware date and time handler. More...
Public Member Functions | |
| adjustDateTime ($hour, $minute=0, $second=0, $month=0, $day=0, $year=0) | |
| attribute ($name) | |
| attributes () | |
| day () | |
| duplicate () | |
| eZDateTime ($datetime=false) | |
| hasAttribute ($name) | |
| hour () | |
| isEqualTo (&$datetime) | |
| isGreaterThan (&$datetime, $equal=false) | |
| isValid () | |
| locale () | |
| minute () | |
| month () | |
| second () | |
| setDay ($day) | |
| setHMS ($hour, $min=0, $sec=0) | |
| setHour ($hour) | |
| setLocale ($locale) | |
| setMDY ($month, $day=0, $year=0) | |
| setMDYHMS ($month, $day, $year, $hour, $min, $sec=0) | |
| setMinute ($min) | |
| setMonth ($month) | |
| setSecond ($sec) | |
| setTimeStamp ($stamp) | |
| setYear ($year) | |
| timeStamp () | |
| timeZone () | |
| toDate () | |
| toString ($short=false) | |
| toTime () | |
| year () | |
Static Public Member Functions | |
| static | create ($hour=-1, $minute=-1, $second=-1, $month=-1, $day=-1, $year=-1) |
| static | currentTimeStamp () |
Public Attributes | |
| $DateTime | |
| The current datetime as a timestamp. | |
| $IsValid | |
| $Locale | |
| Locale object, is just a reference to minimize memory usage. | |
Locale aware date and time handler.
eZDateTime handles 24 hour time values in hours, minutes and seconds and date values. The datetime stored as a timestamp with the number of seconds since the epoch. See PHP function date() and time() for more information.
A new instance of eZDateTime will automaticly use the current locale and current datetime, if you however want a different locale use the setLocale() function. The current locale can be fetched with locale().
Change the time directly with setHour(), setMinute(), setSecond() and setHMS(). Change the date directly with setYear(), setMonth(), setDay() and setMDY(). You can also adjust the date time relative to it's current value by using adjustDateTime(). Use timeStamp() to get the current timestamp value or year(), month(), day(), hour(), minute() and second() for the respective values.
When creating new datetimes you're advised to use the static create() function which returns a new eZDateTime object. You can also create a copy with the duplicate() function.
Time 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/ezdatetime.php' ); $us_locale = eZLocale::instance( 'us' ); $dt1 = new eZDateTime(); $dt2 = eZDateTime::create(); $dt2->setLocale( $us_locale ); $dt2->adjustDateTime( -8, 0, 0, 1, 2, 3 ); $dt3 = $dt1->duplicate(); print( $dt1->toString() ); print( $dt2->toString( true ) ); print( $dt1->isEqualTo( $dt3 ) ? 'true' : 'false' ); // Prints 'true'
Definition at line 83 of file ezdatetime.php.
| eZDateTime::adjustDateTime | ( | $ | hour, |
| $ | minute = 0, |
||
| $ | second = 0, |
||
| $ | month = 0, |
||
| $ | day = 0, |
||
| $ | year = 0 |
||
| ) |
Adjusts the datetime relative to it's current value. This is useful for adding/subtracting hours, minutes, seconds, years, months or days to an existing datetime.
Definition at line 400 of file ezdatetime.php.
| eZDateTime::attribute | ( | $ | name | ) |
Definition at line 132 of file ezdatetime.php.
| eZDateTime::attributes | ( | ) |
Definition at line 115 of file ezdatetime.php.
Referenced by hasAttribute().
| static eZDateTime::create | ( | $ | hour = -1, |
| $ | minute = -1, |
||
| $ | second = -1, |
||
| $ | month = -1, |
||
| $ | day = -1, |
||
| $ | year = -1 |
||
| ) | [static] |
Creates a new eZDate object with the time values $hour, $minute and $second, date values $month, $day and $year and returns a reference to it. Any value can be ommitted or set to -1 to use the current date or time value.
Definition at line 472 of file ezdatetime.php.
| static eZDateTime::currentTimeStamp | ( | ) | [static] |
Returns the current date and time as a UNIX timestamp
Definition at line 224 of file ezdatetime.php.
Referenced by eZContentFunctions\createAndPublishObject().
| eZDateTime::day | ( | ) |
| eZDateTime::duplicate | ( | ) |
Definition at line 495 of file ezdatetime.php.
| eZDateTime::eZDateTime | ( | $ | datetime = false | ) |
Creates a new datetime object with default locale, if $datetime is not supplied the current datetime is used.
Definition at line 89 of file ezdatetime.php.
Referenced by create().
| eZDateTime::hasAttribute | ( | $ | name | ) |
Definition at line 127 of file ezdatetime.php.
| eZDateTime::hour | ( | ) |
| eZDateTime::isEqualTo | ( | &$ | datetime | ) |
Returns true if this object is equal to $date. $date can be specified as a timestamp value or as an eZDateTime, eZDate or eZTime object.
Definition at line 446 of file ezdatetime.php.
| eZDateTime::isGreaterThan | ( | &$ | datetime, |
| $ | equal = false |
||
| ) |
Returns true if this object has a datetime greater than $datetime. $datetime can be specified as a timestamp value or as an eZDateTime, eZDate or eZTime object. If $equal is true it returns true if they are equal as well.
Definition at line 415 of file ezdatetime.php.
| eZDateTime::isValid | ( | ) |
Definition at line 176 of file ezdatetime.php.
Referenced by attribute().
| eZDateTime::locale | ( | ) |
Returns the current locale.
Definition at line 192 of file ezdatetime.php.
| eZDateTime::minute | ( | ) |
Returns the minute element.
Definition at line 286 of file ezdatetime.php.
Referenced by attribute().
| eZDateTime::month | ( | ) |
Returns the month element.
Definition at line 262 of file ezdatetime.php.
Referenced by attribute().
| eZDateTime::second | ( | ) |
Returns the second element.
Definition at line 294 of file ezdatetime.php.
Referenced by attribute().
| eZDateTime::setDay | ( | $ | day | ) |
Sets the day leaving the other elements untouched.
Definition at line 322 of file ezdatetime.php.
| eZDateTime::setHMS | ( | $ | hour, |
| $ | min = 0, |
||
| $ | sec = 0 |
||
| ) |
Sets all hour, minute and second elements leaving the other elements untouched.
Definition at line 362 of file ezdatetime.php.
| eZDateTime::setHour | ( | $ | hour | ) |
Sets the hour leaving the other elements untouched.
Definition at line 332 of file ezdatetime.php.
| eZDateTime::setLocale | ( | $ | locale | ) |
Sets the locale to $locale which is used in text output.
Definition at line 184 of file ezdatetime.php.
| eZDateTime::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 381 of file ezdatetime.php.
| eZDateTime::setMDYHMS | ( | $ | month, |
| $ | day, | ||
| $ | year, | ||
| $ | hour, | ||
| $ | min, | ||
| $ | sec = 0 |
||
| ) |
Sets all hour, minute and second elements leaving the other elements untouched.
Definition at line 372 of file ezdatetime.php.
| eZDateTime::setMinute | ( | $ | min | ) |
Sets the minute leaving the other elements untouched.
Definition at line 342 of file ezdatetime.php.
| eZDateTime::setMonth | ( | $ | month | ) |
Sets the month leaving the other elements untouched.
Definition at line 312 of file ezdatetime.php.
| eZDateTime::setSecond | ( | $ | sec | ) |
Sets the second leaving the other elements untouched.
Definition at line 352 of file ezdatetime.php.
| eZDateTime::setTimeStamp | ( | $ | stamp | ) |
Definition at line 214 of file ezdatetime.php.
| eZDateTime::setYear | ( | $ | year | ) |
Sets the year leaving the other elements untouched.
Definition at line 302 of file ezdatetime.php.
| eZDateTime::timeStamp | ( | ) |
Returns the timestamp value, this is the number of seconds since the epoch.
Definition at line 209 of file ezdatetime.php.
Referenced by attribute(), isEqualTo(), and isGreaterThan().
| eZDateTime::timeZone | ( | ) |
Returns the current time zone.
Definition at line 200 of file ezdatetime.php.
| eZDateTime::toDate | ( | ) |
Creates an eZDate object of this datetime with the same date and locale. Returns a reference to the object.
Definition at line 233 of file ezdatetime.php.
Referenced by isEqualTo(), and isGreaterThan().
| eZDateTime::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 505 of file ezdatetime.php.
| eZDateTime::toTime | ( | ) |
Creates an eZTime object of this datetime with the same time and locale. Returns a reference to the object.
Definition at line 244 of file ezdatetime.php.
Referenced by isEqualTo(), and isGreaterThan().
| eZDateTime::year | ( | ) |
| eZDateTime::$DateTime |
The current datetime as a timestamp.
Definition at line 519 of file ezdatetime.php.
| eZDateTime::$IsValid |
Definition at line 520 of file ezdatetime.php.
| eZDateTime::$Locale |
Locale object, is just a reference to minimize memory usage.
Definition at line 517 of file ezdatetime.php.