PHP Класс Horde_Date, horde

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

Защищенные свойства (Protected)

Свойство Тип Описание
$_corrections array Map of required correction masks.
$_defaultFormat string Default format for __toString()
$_defaultSpecs string Default specs that are always supported.
$_formatCache
$_hour integer Hour
$_mday integer Day
$_min integer Minute
$_month integer Month
$_sec integer Second
$_supportedSpecs string Internally supported strftime() specifiers.
$_timezone string String representation of the date's timezone.
$_timezoneAbbreviations array These aliases map timezone abbreviations to those understood by PHP.
$_timezoneAliases array These aliases map Windows, Lotus, and other Timezone IDs to those understood by PHP.
$_timezoneIdentifiers array A list of (Olson) timezone identifiers understood by PHP.
$_year integer Year

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

Метод Описание
__construct ( $date = null, $timezone = null ) Builds a new date object. If $date contains date parts, use them to initialize the object.
__get ( string $name ) : integer | string Getter for the date and time properties.
__isset ( string $name ) : boolen Returns whether a date or time property exists.
__set ( string $name, integer | string $value ) Setter for the date and time properties.
__toString ( ) : string Returns a simple string representation of the date object
add ( $factor ) Adds a number of seconds or units to this date, returning a new Date object.
after ( mixed $other ) : boolean Returns whether this date is after the other.
before ( mixed $other ) : boolean Returns whether this date is before the other.
compareDate ( mixed $other ) : integer Compares this date to another date object to see which one is greater (later). Assumes that the dates are in the same timezone.
compareDateTime ( mixed $other ) : integer Compares this to another date object, including times, to see which one is greater (later). Assumes that the dates are in the same timezone.
compareTime ( mixed $other ) : integer Compares this to another date object by time, to see which one is greater (later). Assumes that the dates are in the same timezone.
dateString ( ) : string Formats date and time to be passed around as a short url parameter.
datestamp ( ) : integer Returns the unix timestamp representation of this date, 12:00am.
dayOfWeek ( ) : integer Returns the day of the week (0 = Sunday, 6 = Saturday) of this date.
dayOfYear ( ) : integer Returns the day number of the year (1 to 365/366).
diff ( Horde_Date $other ) : integer Returns number of days between this date and another.
equals ( mixed $other ) : boolean Returns whether this date is the same like the other.
format ( string $format ) : string Formats time using the specifiers available in date() or in the DateTime class' format() method.
fromDays ( integer $days ) : Horde_Date Converts number of days since 24th November, 4714 B.C. (in the proleptic Gregorian calendar, which is year -4713 using 'Astronomical' year numbering) to Gregorian calendar date.
getTimezoneAlias ( string $timezone ) : string Returns the normalized (Olson) timezone name of a timezone alias.
isValid ( ) : boolean Is the date currently represented by this object a valid date?
setDefaultFormat ( string $format ) Sets the default date format used in __toString()
setNthWeekday ( integer $weekday, integer $nth = 1 ) Sets the date of this object to the $nth weekday of $weekday.
setTimezone ( string $timezone ) : Horde_Date Converts this object to a different timezone.
strftime ( $format ) : string Formats date and time using strftime() format.
sub ( $factor ) Subtracts a number of seconds or units from this date, returning a new Horde_Date object.
timestamp ( ) : integer Returns the unix timestamp representation of this date.
toDateTime ( ) : DateTime Returns a DateTime object representing this object.
toDays ( ) : integer Converts a date in the proleptic Gregorian calendar to the no of days since 24th November, 4714 B.C.
toJson ( ) : string Formats date and time to the ISO format used by JSON.
toiCalendar ( boolean $floating = false ) : string Formats date and time to the RFC 2445 iCalendar DATE-TIME format.
tzOffset ( boolean $colon = true ) : string Returns the time offset for local time zone.
weekOfMonth ( ) : integer Returns the week of the month.
weekOfYear ( ) : integer Returns the week of the year, first Monday is first day of first week.
weeksInYear ( integer $year ) : integer Returns the number of weeks in the given year (52 or 53).

Защищенные методы

Метод Описание
_correct ( integer $mask = self::MASK_ALLPARTS, integer $down = false ) Corrects any over- or underflows in any of the date's members.
_correctMonth ( ) Corrects the current month.
_initializeFromArgs ( $args ) Handles args in order: year month day hour min sec tz
_initializeFromArray ( $date )
_initializeFromObject ( $date )
_initializeTimezone ( $timezone )
_regexCallback ( $reg ) : string Callback used to replace a strtime pattern
_strftime ( $format ) : string Formats date and time using a limited set of the strftime() format.

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

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

Recognized formats: - arrays with keys 'year', 'month', 'mday', 'day' 'hour', 'min', 'minute', 'sec' - objects with properties 'year', 'month', 'mday', 'hour', 'min', 'sec' - yyyy-mm-dd hh:mm:ss - yyyymmddhhmmss - yyyymmddThhmmssZ - yyyymmdd (might conflict with unix timestamps between 31 Oct 1966 and 03 Mar 1973) - unix timestamps - anything parsed by strtotime()/DateTime.
public __construct ( $date = null, $timezone = null )

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

Getter for the date and time properties.
public __get ( string $name ) : integer | string
$name string One of 'year', 'month', 'mday', 'hour', 'min', 'sec' or 'timezone' (since Horde_Date 2.0.0).
Результат integer | string The property value, or null if not set.

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

Returns whether a date or time property exists.
public __isset ( string $name ) : boolen
$name string One of 'year', 'month', 'mday', 'hour', 'min' or 'sec'.
Результат boolen True if the property exists and is set.

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

Setter for the date and time properties.
public __set ( string $name, integer | string $value )
$name string One of 'year', 'month', 'mday', 'hour', 'min', 'sec' or 'timezone' (since Horde_Date 2.0.0).
$value integer | string The property value.

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

Returns a simple string representation of the date object
public __toString ( ) : string
Результат string This object converted to a string.

_correct() защищенный Метод

Corrects any over- or underflows in any of the date's members.
protected _correct ( integer $mask = self::MASK_ALLPARTS, integer $down = false )
$mask integer We may not want to correct some overflows.
$down integer Whether to correct the date up or down.

_correctMonth() защищенный Метод

This cannot be done in _correct() because that would also trigger a correction of the day, which would result in an infinite loop.
protected _correctMonth ( )

_initializeFromArgs() защищенный Метод

Handles args in order: year month day hour min sec tz
protected _initializeFromArgs ( $args )

_initializeFromArray() защищенный Метод

protected _initializeFromArray ( $date )

_initializeFromObject() защищенный Метод

protected _initializeFromObject ( $date )

_initializeTimezone() защищенный Метод

protected _initializeTimezone ( $timezone )

_regexCallback() защищенный Метод

Callback used to replace a strtime pattern
protected _regexCallback ( $reg ) : string
Результат string Replacement string.

_strftime() защищенный Метод

Formats date and time using a limited set of the strftime() format.
protected _strftime ( $format ) : string
Результат string strftime() formatted date and time.

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

Adds a number of seconds or units to this date, returning a new Date object.
public add ( $factor )

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

Returns whether this date is after the other.
public after ( mixed $other ) : boolean
$other mixed The date to compare to.
Результат boolean True if this date is after the other.

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

Returns whether this date is before the other.
public before ( mixed $other ) : boolean
$other mixed The date to compare to.
Результат boolean True if this date is before the other.

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

Compares this date to another date object to see which one is greater (later). Assumes that the dates are in the same timezone.
public compareDate ( mixed $other ) : integer
$other mixed The date to compare to.
Результат integer == 0 if they are on the same date >= 1 if $this is greater (later) <= -1 if $other is greater (later)

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

Compares this to another date object, including times, to see which one is greater (later). Assumes that the dates are in the same timezone.
public compareDateTime ( mixed $other ) : integer
$other mixed The date to compare to.
Результат integer == 0 if they are equal >= 1 if $this is greater (later) <= -1 if $other is greater (later)

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

Compares this to another date object by time, to see which one is greater (later). Assumes that the dates are in the same timezone.
public compareTime ( mixed $other ) : integer
$other mixed The date to compare to.
Результат integer == 0 if they are at the same time >= 1 if $this is greater (later) <= -1 if $other is greater (later)

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

Formats date and time to be passed around as a short url parameter.
public dateString ( ) : string
Результат string Date and time.

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

Returns the unix timestamp representation of this date, 12:00am.
public datestamp ( ) : integer
Результат integer A unix timestamp.

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

Returns the day of the week (0 = Sunday, 6 = Saturday) of this date.
public dayOfWeek ( ) : integer
Результат integer The day of the week.

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

Returns the day number of the year (1 to 365/366).
public dayOfYear ( ) : integer
Результат integer The day of the year.

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

Returns number of days between this date and another.
public diff ( Horde_Date $other ) : integer
$other Horde_Date The other day to diff with.
Результат integer The absolute number of days between the two dates.

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

Returns whether this date is the same like the other.
public equals ( mixed $other ) : boolean
$other mixed The date to compare to.
Результат boolean True if this date is the same like the other.

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

To format in languages other than English, use strftime() instead.
public format ( string $format ) : string
$format string
Результат string Formatted time.

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

Returned date belongs to the proleptic Gregorian calendar, using 'Astronomical' year numbering. The algorithm is valid for all years (positive and negative), and also for years preceding 4714 B.C. (i.e. for negative 'Julian Days'), and so the only limitation is platform-dependent (for 32-bit systems the maximum year would be something like about 1,465,190 A.D.). N.B. Monday, 24th November, 4714 B.C. is Julian Day '0'. Algorithm is from PEAR::Date_Calc
Автор: Monte Ohrt ([email protected])
Автор: Pierre-Alain Joye ([email protected])
Автор: Daniel Convissor ([email protected])
Автор: C.A. Woodcock ([email protected])
public static fromDays ( integer $days ) : Horde_Date
$days integer the number of days since 24th November, 4714 B.C.
Результат Horde_Date A Horde_Date object representing the date.

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

We currently support Windows and Lotus timezone names, and timezone abbreviations.
public static getTimezoneAlias ( string $timezone ) : string
$timezone string Some timezone alias.
Результат string The Olson timezone name, or the original value, if no alias found.

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

Is the date currently represented by this object a valid date?
public isValid ( ) : boolean
Результат boolean Validity, counting leap years, etc.

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

Sets the default date format used in __toString()
public setDefaultFormat ( string $format )
$format string

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

Sets the date of this object to the $nth weekday of $weekday.
public setNthWeekday ( integer $weekday, integer $nth = 1 )
$weekday integer The day of the week (0 = Sunday, etc).
$nth integer The $nth $weekday to set to (defaults to 1). Negative values count from end of the month (@since Horde_Date 2.1.0).

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

Converts this object to a different timezone.
public setTimezone ( string $timezone ) : Horde_Date
$timezone string The new timezone.
Результат Horde_Date This object.

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

Formats date and time using strftime() format.
public strftime ( $format ) : string
Результат string strftime() formatted date and time.

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

Subtracts a number of seconds or units from this date, returning a new Horde_Date object.
public sub ( $factor )

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

Returns the unix timestamp representation of this date.
public timestamp ( ) : integer
Результат integer A unix timestamp.

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

Returns a DateTime object representing this object.
public toDateTime ( ) : DateTime
Результат DateTime

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

Returns the no of days since Monday, 24th November, 4714 B.C. in the proleptic Gregorian calendar (which is 24th November, -4713 using 'Astronomical' year numbering, and 1st January, 4713 B.C. in the proleptic Julian calendar). This is also the first day of the 'Julian Period' proposed by Joseph Scaliger in 1583, and the number of days since this date is known as the 'Julian Day'. (It is not directly to do with the Julian calendar, although this is where the name is derived from.) The algorithm is valid for all years (positive and negative), and also for years preceding 4714 B.C. Algorithm is from PEAR::Date_Calc
Автор: Monte Ohrt ([email protected])
Автор: Pierre-Alain Joye ([email protected])
Автор: Daniel Convissor ([email protected])
Автор: C.A. Woodcock ([email protected])
public toDays ( ) : integer
Результат integer The number of days since 24th November, 4714 B.C.

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

Formats date and time to the ISO format used by JSON.
public toJson ( ) : string
Результат string Date and time.

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

Formats date and time to the RFC 2445 iCalendar DATE-TIME format.
public toiCalendar ( boolean $floating = false ) : string
$floating boolean Whether to return a floating date-time (without time zone information).
Результат string Date and time.

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

Returns the time offset for local time zone.
public tzOffset ( boolean $colon = true ) : string
$colon boolean Place a colon between hours and minutes?
Результат string Timezone offset as a string in the format +HH:MM.

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

Returns the week of the month.
public weekOfMonth ( ) : integer
Результат integer The week number.

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

Returns the week of the year, first Monday is first day of first week.
public weekOfYear ( ) : integer
Результат integer The week number.

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

Returns the number of weeks in the given year (52 or 53).
public static weeksInYear ( integer $year ) : integer
$year integer The year to count the number of weeks in.
Результат integer $numWeeks The number of weeks in $year.

Описание свойств

$_corrections защищенное статическое свойство

Map of required correction masks.
См. также: __set()
protected static array $_corrections
Результат array

$_defaultFormat защищенное свойство

Default format for __toString()
protected string $_defaultFormat
Результат string

$_defaultSpecs защищенное статическое свойство

Default specs that are always supported.
protected static string $_defaultSpecs
Результат string

$_formatCache защищенное свойство

protected $_formatCache

$_hour защищенное свойство

Hour
protected int $_hour
Результат integer

$_mday защищенное свойство

Day
protected int $_mday
Результат integer

$_min защищенное свойство

Minute
protected int $_min
Результат integer

$_month защищенное свойство

Month
protected int $_month
Результат integer

$_sec защищенное свойство

Second
protected int $_sec
Результат integer

$_supportedSpecs защищенное статическое свойство

Internally supported strftime() specifiers.
protected static string $_supportedSpecs
Результат string

$_timezone защищенное свойство

String representation of the date's timezone.
protected string $_timezone
Результат string

$_timezoneAbbreviations защищенное статическое свойство

These aliases map timezone abbreviations to those understood by PHP.
См. также: getTimezoneAlias()
protected static array $_timezoneAbbreviations
Результат array

$_timezoneAliases защищенное статическое свойство

These aliases map Windows, Lotus, and other Timezone IDs to those understood by PHP.
protected static array $_timezoneAliases
Результат array

$_timezoneIdentifiers защищенное статическое свойство

A list of (Olson) timezone identifiers understood by PHP.
См. также: getTimezoneAlias()
protected static array $_timezoneIdentifiers
Результат array

$_year защищенное свойство

Year
protected int $_year
Результат integer