PHP 클래스 Habari\DateTime

상속: extends DateTime
파일 보기 프로젝트 열기: habari/system 1 사용 예제들

공개 메소드들

메소드 설명
__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