Method | Description | |
---|---|---|
__get ( $property ) | Magic method to get magic ponies. | |
__static ( ) | Set default timezone to system default on init. | |
__toString ( ) : string | Magic method called when this object is cast to string. Returns the unix timestamp of this object. | |
create ( string $time = null, string $timezone = null ) : |
Helper function to create a DateTime object for the given time and timezone. If no time is given, defaults to 'now'. If no timezone given defaults to timezone set in {@link set_default_timezone()} | |
date_create ( $time = null, $timezone = null ) | This function should not be used. Use ::create() instead | |
difference ( mixed $start_date, mixed $end_date ) : array | Returns an array representing the difference between two times by interval. | |
format ( string $format = null ) : string | Returns date formatted according to given format. | |
friendly ( integer $precision = 7, boolean $include_suffix = true, $comparison_date = 'now' ) : string | Returns a friendlier string version of the time, ie: 3 days, 1 hour, and 5 minutes ago | |
fuzzy ( $comparison_date = 'now' ) | Similar to friendly(), but much more. | |
get ( $format = null ) | ||
get_default_date_format ( ) : string | Return the default date format, as set in the Options table | |
get_default_datetime_format ( ) : string | Get the default date/time format set. | |
get_default_time_format ( ) : string | Return the default time format, as set in the Options table | |
get_default_timezone ( ) | Get the timezone for Habari and PHP. | |
get_last_exception ( ) | Get the last exception thrown when trying to create | |
get_timezone ( ) : DateTimeZone | Get the timezone identifier that is set for this datetime object. | |
getdate ( ) : array | Returns an associative array containing the date information for this DateTime object, as per {@link http://php.net/getdate getdate()} | |
modify ( string $args ) : |
Alters the timestamp | |
out ( string $format = null ) | Echos date formatted according to given format. | |
set_date ( integer $year, integer $month, integer $day ) : |
Set the date of this object | |
set_default_date_format ( string $format ) | Set default date format. The format is the same as the internal php {@link http://ca.php.net/date date() function}. | |
set_default_datetime_format ( string $format ) | Set default date/time format. The format is the same as the internal php {@link http://ca.php.net/date date() function}. | |
set_default_time_format ( string $format ) | Set default time format. The format is the same as the internal php {@link http://ca.php.net/date date() function}. | |
set_default_timezone ( string $timezone ) | Sets the timezone for Habari and PHP. | |
set_isodate ( integer $year, $week, integer $day = null ) : |
Sets the ISO date | |
set_time ( integer $hour, integer $minute, integer $second = null ) : |
Set the time of this object | |
set_timezone ( mixed $timezone ) : |
Set the timezone for this datetime object. Can be either string timezone identifier, or DateTimeZone object. | |
text_format ( string $format ) : string | Returns date components inserted into a string |
Method | Description | |
---|---|---|
text_format_callback ( array $matches ) : string | Callback method for supplying replacements for HabariDatTime::text_format() |
public static __static ( ) |
public __toString ( ) : string | ||
return | string | The unix timestamp |
public static date_create ( $time = null, $timezone = null ) |
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 public static difference ( mixed $start_date, mixed $end_date ) : array | ||
$start_date | mixed | The start date, as a HDT object or any format accepted by DateTime::create(). |
$end_date | mixed | The end date, as a HDT object or any format accepted by DateTime::create(). |
return | array | Array of each interval and whether the interval is inverted or not. |
public friendly ( integer $precision = 7, boolean $include_suffix = true, $comparison_date = 'now' ) : string | ||
$precision | integer | Only display x intervals. Note that this does not round, it only limits the display length. |
$include_suffix | boolean | Include the 'ago' or 'from now' suffix? |
return | string | Time passed in the specified units. |
public fuzzy ( $comparison_date = 'now' ) |
public static get_default_date_format ( ) : string | ||
return | string | The default date format |
public static get_default_datetime_format ( ) : string | ||
return | string | The date format set. |
public static get_default_time_format ( ) : string | ||
return | string | The default time format |
public static get_default_timezone ( ) |
public static get_last_exception ( ) |
public get_timezone ( ) : DateTimeZone | ||
return | DateTimeZone | The timezone object. |
public static set_default_date_format ( string $format ) | ||
$format | string | The date format. |
public static set_default_datetime_format ( string $format ) | ||
$format | string | The date format. |
public static set_default_time_format ( string $format ) | ||
$format | string | The time format. |
public static set_default_timezone ( string $timezone ) | ||
$timezone | string | A timezone name, not an abbreviation, for example 'America/New York' |
public set_isodate ( integer $year, $week, integer $day = null ) : |
||
$year | integer | Year of the date |
$day | integer | Day of the date |
return |
public set_timezone ( mixed $timezone ) : |
||
$timezone | mixed | The timezone to use. |
return | $this object. |
public text_format ( string $format ) : string | ||
$format | string | A string with single-character date format codes {@link http://php.net/date date()} surrounded by braces |
return | string | The string with date components inserted |