Public Member Functions | Static Public Member Functions | Public Attributes

DateTime Class Reference

List of all members.

Public Member Functions

 set_date ($year, $month, $day)
 set_isodate ($year, $week, $day=null)
 set_time ($hour, $minute, $second=null)
 set_timezone ($timezone)
 get_timezone ()
 format ($format=null)
 text_format ($format)
 modify ($args)
 get ($format=null)
 out ($format=null)
 __toString ()
 __get ($property)
 getdate ()
 friendly ($precision=7, $include_suffix=true, $comparison_date= 'now')
 fuzzy ($comparison_date= 'now')

Static Public Member Functions

static __static ()
static set_default_datetime_format ($format)
static get_default_datetime_format ()
static set_default_timezone ($timezone)
static get_default_timezone ()
static date_create ($time=null, $timezone=null)
static create ($time=null, $timezone=null)
static get_default_date_format ()
static set_default_date_format ($format)
static get_default_time_format ()
static set_default_time_format ($format)
static difference ($start_date, $end_date)

Public Attributes

const YEAR = 31556926
const MONTH = 2629744
const WEEK = 604800
const DAY = 86400
const HOUR = 3600
const MINUTE = 60

Detailed Description

Definition at line 20 of file datetime.php.


Member Function Documentation

DateTime::__get ( property  ) 

Magic method to get magic ponies... properties, I mean.

Definition at line 365 of file datetime.php.

static DateTime::__static (  )  [static]

Set default timezone to system default on init.

Definition at line 40 of file datetime.php.

DateTime::__toString (  ) 

Magic method called when this object is cast to string. Returns the unix timestamp of this object.

Returns:
string The unix timestamp

Definition at line 357 of file datetime.php.

static DateTime::create ( time = null,
timezone = null 
) [static]
static DateTime::date_create ( time = null,
timezone = null 
) [static]

This function should not be used. Use create() instead

Deprecated:

Definition at line 112 of file datetime.php.

static DateTime::difference ( start_date,
end_date 
) [static]

Returns an array representing the difference between two times by interval.

print_r( DateTime::difference( 'now', 'January 1, 2010' ) ); // output (past): Array ( [invert] => [y] => 0 [m] => 9 [w] => 3 [d] => 5 [h] => 22 [i] => 33 [s] => 5 ) print_r( DateTime::difference( 'now', 'January 1, 2011' ) ); // output (future): Array ( [invert] => 1 [y] => 0 [m] => 2 [w] => 0 [d] => 3 [h] => 5 [i] => 33 [s] => 11 )

If 'invert' is true, the time is in the future (ie: x from now). If it is false, the time is in the past (ie: x ago).

For more information, see PHP's DateInterval class, which this and friendly() attempt to emulate for < PHP 5.3

Todo:
Add total_days, total_years, etc. values?
Parameters:
mixed $start_date The start date, as a HDT object or any format accepted by DateTime::create().
mixed $end_date The end date, as a HDT object or any format accepted by DateTime::create().
Returns:
array Array of each interval and whether the interval is inverted or not.

Definition at line 640 of file datetime.php.

Referenced by friendly().

DateTime::format ( format = null  ) 

Returns date formatted according to given format.

See also:
DateTime::format()
Parameters:
string $format Format accepted by date().
Returns:
string The formatted date, false on failure.

Definition at line 232 of file datetime.php.

Referenced by __get(), __toString(), get(), getdate(), and out().

DateTime::friendly ( precision = 7,
include_suffix = true,
comparison_date = 'now' 
)

Returns a friendlier string version of the time, ie: 3 days, 1 hour, and 5 minutes ago

Parameters:
int $precision Only display x intervals. Note that this does not round, it only limits the display length.
boolean $include_suffix Include the 'ago' or 'from now' suffix?
Returns:
string Time passed in the specified units.

Definition at line 478 of file datetime.php.

Referenced by __get().

DateTime::fuzzy ( comparison_date = 'now'  ) 

Similar to friendly(), but much more... fuzzy.

Returns a very short version of the difference in time between now and the current HDT object.

Definition at line 539 of file datetime.php.

Referenced by __get().

DateTime::get ( format = null  ) 
See also:
format()

Definition at line 335 of file datetime.php.

Referenced by __static().

static DateTime::get_default_date_format (  )  [static]

Return the default date format, as set in the Options table

Returns:
string The default date format

Definition at line 412 of file datetime.php.

static DateTime::get_default_datetime_format (  )  [static]

Get the default date/time format set.

See also:
set_default_datetime_format()
Returns:
string The date format set.

Definition at line 75 of file datetime.php.

static DateTime::get_default_time_format (  )  [static]

Return the default time format, as set in the Options table

Returns:
string The default time format

Definition at line 437 of file datetime.php.

static DateTime::get_default_timezone (  )  [static]

Get the timezone for Habari and PHP. Defaults to system timezone if not set.

See also:
set_default_timezone()

Definition at line 103 of file datetime.php.

DateTime::get_timezone (  ) 

Get the timezone identifier that is set for this datetime object.

Returns:
The timezone object.

Definition at line 220 of file datetime.php.

DateTime::getdate (  ) 

Returns an associative array containing the date information for this DateTime object, as per getdate()

Returns:
array Associative array containing the date information

Definition at line 463 of file datetime.php.

Referenced by __get().

DateTime::modify ( args  ) 

Alters the timestamp

Parameters:
string $args A format accepted by strtotime()..
Returns:
DateTime $this object.

Definition at line 326 of file datetime.php.

DateTime::out ( format = null  ) 

Echos date formatted according to given format.

See also:
format()
Parameters:
string $format Format accepted by date().

Definition at line 346 of file datetime.php.

DateTime::set_date ( year,
month,
day 
)

Set the date of this object

See also:
DateTime::setDate()
Parameters:
int $year Year of the date
int $month Month of the date
int $day Day of the date
Returns:

Definition at line 162 of file datetime.php.

static DateTime::set_default_date_format ( format  )  [static]

Set default date format. The format is the same as the internal php date() function.

Parameters:
string $format The date format.

Definition at line 427 of file datetime.php.

Referenced by get_default_date_format().

static DateTime::set_default_datetime_format ( format  )  [static]

Set default date/time format. The format is the same as the internal php date() function.

Parameters:
string $format The date format.

Definition at line 63 of file datetime.php.

Referenced by __static(), and get_default_datetime_format().

static DateTime::set_default_time_format ( format  )  [static]

Set default time format. The format is the same as the internal php date() function.

Parameters:
string $format The time format.

Definition at line 452 of file datetime.php.

Referenced by get_default_time_format().

static DateTime::set_default_timezone ( timezone  )  [static]

Sets the timezone for Habari and PHP.

Parameters:
string $timezone A timezone name, not an abbreviation, for example 'America/New York'

Definition at line 90 of file datetime.php.

Referenced by __static().

DateTime::set_isodate ( year,
week,
day = null 
)

Sets the ISO date

See also:
DateTime::setISODate()
Parameters:
int $year Year of the date
int $month Month of the date
int $day Day of the date
Returns:

Definition at line 177 of file datetime.php.

DateTime::set_time ( hour,
minute,
second = null 
)

Set the time of this object

See also:
DateTime::setTime()
Parameters:
int $hour Hour of the time
int $minute Minute of the time
int $second Second of the time
Returns:

Definition at line 192 of file datetime.php.

DateTime::set_timezone ( timezone  ) 

Set the timezone for this datetime object. Can be either string timezone identifier, or DateTimeZone object.

See also:
DateTime::setTimezone()
Parameters:
mixed $timezone The timezone to use.
Returns:
DateTime $this object.

Definition at line 206 of file datetime.php.

DateTime::text_format ( format  ) 

Returns date components inserted into a string

Example: echo DateTime::create('2010-01-01')->text_format('The year was {Y}.'); // Expected output: The year was 2010.

Parameters:
string $format A string with single-character date format codes date() surrounded by braces
Returns:
string The string with date components inserted

Definition at line 304 of file datetime.php.


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