eZDateTime Class Reference
[Locale system]

Locale aware date and time handler. More...

List of all members.


Public Methods

 eZDateTime ($datetime=false)
isValid ()
 setLocale (&$locale)
locale ()
timeZone ()
timeStamp ()
toDate ()
toTime ()
year ()
month ()
day ()
hour ()
minute ()
second ()
 setYear ($year)
 setMonth ($month)
 setDay ($day)
 setHour ($hour)
 setMinute ($min)
 setSecond ($sec)
 setHMS ($hour,$min=0,$sec=0)
 setMDYHMS ($month,$day,$year,$hour,$min,$sec=0)
 setMDY ($month,$day=0,$year=0)
 adjustDateTime ($hour,$minute=0,$second=0,$month=0,$day=0,$year=0)
 isGreaterThan (&$datetime,$equal=false)
 isEqualTo (&$datetime)
create ($hour=-1,$minute=-1,$second=-1,$month=-1,$day=-1,$year=-1)
duplicate ()
toString ($short=false)

Static Public Methods

currentTimeStamp ()

Public Attributes

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

 DateTime
 The current datetime as a timestamp.


Detailed Description

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 mktime() 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'

See also:
eZLocale

Definition at line ezdatetime.php.


Constructor & Destructor Documentation

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 ezdatetime.php.

References year().

Referenced by duplicate().


Member Function Documentation

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 ezdatetime.php.

References year().

& eZDateTime::create   hour = -1,
  minute = -1,
  second = -1,
  month = -1,
  day = -1,
  year = -1
 

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 ezdatetime.php.

References year().

& eZDateTime::currentTimeStamp   [static]
 

Returns the current date and time as a UNIX timestamp

Definition at line ezdatetime.php.

Referenced by eZURL::setModified().

& eZDateTime::day  
 

Returns the day element.

Definition at line ezdatetime.php.

Referenced by setMDYHMS().

& eZDateTime::duplicate  
 

Creates an exact copy of this object and returns a reference to it.

Definition at line ezdatetime.php.

References eZDateTime().

& eZDateTime::hour  
 

Returns the hour element.

Definition at line ezdatetime.php.

Referenced by setMDYHMS().

eZDateTime::isEqualTo &$    datetime
 

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

Note:
If $datetime is either eZTime it will create temporary objects with toDate() and toTime() and use these for comparison.

Definition at line ezdatetime.php.

References toTime().

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, eZTime object. If $equal is true it returns true if they are equal as well.

Note:
If $datetime is either eZTime it will create temporary objects with toDate() and toTime() and use these for comparison.

Definition at line ezdatetime.php.

References toTime().

& eZDateTime::isValid  
 

Returns:
true if the date has valid data.

Definition at line ezdatetime.php.

& eZDateTime::locale  
 

Returns a reference to the current locale.

Definition at line ezdatetime.php.

References Locale.

Referenced by setLocale().

& eZDateTime::minute  
 

Returns the minute element.

Definition at line ezdatetime.php.

Referenced by create().

& eZDateTime::month  
 

Returns the month element.

Definition at line ezdatetime.php.

Referenced by setMonth().

& eZDateTime::second  
 

Returns the second element.

Definition at line ezdatetime.php.

Referenced by create().

eZDateTime::setDay   day
 

Sets the day leaving the other elements untouched.

Definition at line ezdatetime.php.

References year().

eZDateTime::setHMS   hour,
  min = 0,
  sec = 0
 

Sets all hour, minute and second elements leaving the other elements untouched.

Definition at line ezdatetime.php.

References year().

eZDateTime::setHour   hour
 

Sets the hour leaving the other elements untouched.

Definition at line ezdatetime.php.

References year().

eZDateTime::setLocale &$    locale
 

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

Definition at line ezdatetime.php.

References locale().

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 ezdatetime.php.

References year().

eZDateTime::setMDYHMS   month,
  day,
  year,
  hour,
  min,
  sec = 0
 

Sets all hour, minute and second elements leaving the other elements untouched.

Definition at line ezdatetime.php.

References year().

eZDateTime::setMinute   min
 

Sets the minute leaving the other elements untouched.

Definition at line ezdatetime.php.

References year().

eZDateTime::setMonth   month
 

Sets the month leaving the other elements untouched.

Definition at line ezdatetime.php.

References year().

eZDateTime::setSecond   sec
 

Sets the second leaving the other elements untouched.

Definition at line ezdatetime.php.

References year().

eZDateTime::setYear   year
 

Sets the year leaving the other elements untouched.

Definition at line ezdatetime.php.

References year().

& eZDateTime::timeStamp  
 

Returns the timestamp value, this is the number of seconds since the epoch.

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

Definition at line ezdatetime.php.

References DateTime.

Referenced by isGreaterThan().

& eZDateTime::timeZone  
 

Returns the current time zone.

Definition at line 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 ezdatetime.php.

Referenced by 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 ezdatetime.php.

References Locale.

& eZDateTime::toTime  
 

Creates an eZTime object of this datetime with the same time and locale. Returns a reference to the object.

Definition at line ezdatetime.php.

Referenced by isGreaterThan().

& eZDateTime::year  
 

Returns the year element.

Definition at line ezdatetime.php.

Referenced by setYear().


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

Exponential