PHP Класс Habari\DateTime

Наследование: extends DateTime
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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 ) : DateTime 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 ) : DateTime Alters the timestamp
out ( string $format = null ) Echos date formatted according to given format.
set_date ( integer $year, integer $month, integer $day ) : DateTime 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 ) : DateTime Sets the ISO date
set_time ( integer $hour, integer $minute, integer $second = null ) : DateTime Set the time of this object
set_timezone ( mixed $timezone ) : DateTime 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

Приватные методы

Метод Описание
text_format_callback ( array $matches ) : string Callback method for supplying replacements for HabariDatTime::text_format()

Описание методов

__get() публичный Метод

.. properties, I mean.
public __get ( $property )

__static() публичный статический Метод

Set default timezone to system default on init.
public static __static ( )

__toString() публичный Метод

Magic method called when this object is cast to string. Returns the unix timestamp of this object.
public __toString ( ) : string
Результат string The unix timestamp

create() публичный статический Метод

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()}
См. также: DateTime::__construct()
public static create ( string $time = null, string $timezone = null ) : DateTime
$time string String in a format accepted by {@link http://ca.php.net/strtotime strtotime()}, defaults to "now".
$timezone string A timezone name, not an abbreviation.
Результат DateTime

date_create() публичный статический Метод

This function should not be used. Use ::create() instead
Устаревший:
public static date_create ( $time = null, $timezone = null )

difference() публичный статический Метод

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().
Результат array Array of each interval and whether the interval is inverted or not.

format() публичный Метод

Returns date formatted according to given format.
См. также: DateTime::format()
public format ( string $format = null ) : string
$format string Format accepted by {@link http://php.net/date date()}.
Результат string The formatted date, false on failure.

friendly() публичный Метод

Returns a friendlier string version of the time, ie: 3 days, 1 hour, and 5 minutes ago
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?
Результат string Time passed in the specified units.

fuzzy() публичный Метод

.. fuzzy. Returns a very short version of the difference in time between now and the current HDT object.
public fuzzy ( $comparison_date = 'now' )

get() публичный Метод

См. также: format()
public get ( $format = null )

get_default_date_format() публичный статический Метод

Return the default date format, as set in the Options table
public static get_default_date_format ( ) : string
Результат string The default date format

get_default_datetime_format() публичный статический Метод

Get the default date/time format set.
См. также: set_default_datetime_format()
public static get_default_datetime_format ( ) : string
Результат string The date format set.

get_default_time_format() публичный статический Метод

Return the default time format, as set in the Options table
public static get_default_time_format ( ) : string
Результат string The default time format

get_default_timezone() публичный статический Метод

Defaults to system timezone if not set.
См. также: set_default_timezone()
public static get_default_timezone ( )

get_last_exception() публичный статический Метод

Get the last exception thrown when trying to create
public static get_last_exception ( )

get_timezone() публичный Метод

Get the timezone identifier that is set for this datetime object.
public get_timezone ( ) : DateTimeZone
Результат DateTimeZone The timezone object.

getdate() публичный Метод

Returns an associative array containing the date information for this DateTime object, as per {@link http://php.net/getdate getdate()}
public getdate ( ) : array
Результат array Associative array containing the date information

modify() публичный Метод

Alters the timestamp
public modify ( string $args ) : DateTime
$args string A format accepted by {@link http://php.net/strtotime strtotime()}..
Результат DateTime $this object.

out() публичный Метод

Echos date formatted according to given format.
См. также: format()
public out ( string $format = null )
$format string Format accepted by {@link http://php.net/date date()}.

set_date() публичный Метод

Set the date of this object
См. также: DateTime::setDate()
public set_date ( integer $year, integer $month, integer $day ) : DateTime
$year integer Year of the date
$month integer Month of the date
$day integer Day of the date
Результат DateTime

set_default_date_format() публичный статический Метод

Set default date format. The format is the same as the internal php {@link http://ca.php.net/date date() function}.
public static set_default_date_format ( string $format )
$format string The date format.

set_default_datetime_format() публичный статический Метод

Set default date/time format. The format is the same as the internal php {@link http://ca.php.net/date date() function}.
public static set_default_datetime_format ( string $format )
$format string The date format.

set_default_time_format() публичный статический Метод

Set default time format. The format is the same as the internal php {@link http://ca.php.net/date date() function}.
public static set_default_time_format ( string $format )
$format string The time format.

set_default_timezone() публичный статический Метод

Sets the timezone for Habari and PHP.
public static set_default_timezone ( string $timezone )
$timezone string A timezone name, not an abbreviation, for example 'America/New York'

set_isodate() публичный Метод

Sets the ISO date
См. также: DateTime::setISODate()
public set_isodate ( integer $year, $week, integer $day = null ) : DateTime
$year integer Year of the date
$day integer Day of the date
Результат DateTime

set_time() публичный Метод

Set the time of this object
См. также: DateTime::setTime()
public set_time ( integer $hour, integer $minute, integer $second = null ) : DateTime
$hour integer Hour of the time
$minute integer Minute of the time
$second integer Second of the time
Результат DateTime

set_timezone() публичный Метод

Set the timezone for this datetime object. Can be either string timezone identifier, or DateTimeZone object.
См. также: DateTime::setTimezone()
public set_timezone ( mixed $timezone ) : DateTime
$timezone mixed The timezone to use.
Результат DateTime $this object.

text_format() публичный Метод

Example: echo DateTime::create('2010-01-01')->text_format('The year was {Y}.'); Expected output: The year was 2010.
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
Результат string The string with date components inserted