Documentation

Horde_Date
in package

Horde Date wrapper/logic class, including some calculation functions.

Tags
author

Chuck Hagenbuch chuck@horde.org

author

Jan Schneider jan@horde.org

author

Michael J Rubinsky mrubinsk@horde.org

category

Horde

copyright

2004-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL

Table of Contents

DATE_DEFAULT  = 'Y-m-d H:i:s'
DATE_FRIDAY  = 5
DATE_JSON  = 'Y-m-d\\TH:i:s'
DATE_MONDAY  = 1
DATE_SATURDAY  = 6
DATE_SUNDAY  = 0
DATE_THURSDAY  = 4
DATE_TUESDAY  = 2
DATE_WEDNESDAY  = 3
MASK_ALLDAYS  = 127
MASK_ALLPARTS  = 63
MASK_DAY  = 8
MASK_FRIDAY  = 32
MASK_HOUR  = 4
MASK_MINUTE  = 2
MASK_MONDAY  = 2
MASK_MONTH  = 16
MASK_SATURDAY  = 64
MASK_SECOND  = 1
MASK_SUNDAY  = 1
MASK_THURSDAY  = 16
MASK_TUESDAY  = 4
MASK_WEDNESDAY  = 8
MASK_WEEKDAYS  = 62
MASK_WEEKEND  = 65
MASK_YEAR  = 32
$_corrections  : array<string|int, mixed>
Map of required correction masks.
$_defaultFormat  : string
Default format for __toString()
$_defaultSpecs  : string
Default specs that are always supported.
$_formatCache  : mixed
$_hour  : int
Hour
$_mday  : int
Day
$_min  : int
Minute
$_month  : int
Month
$_sec  : int
Second
$_supportedSpecs  : string
Internally supported strftime() specifiers.
$_timezone  : string
String representation of the date's timezone.
$_timezoneAbbreviations  : array<string|int, mixed>
These aliases map timezone abbreviations to those understood by PHP.
$_timezoneAliases  : array<string|int, mixed>
These aliases map Windows, Lotus, and other Timezone IDs to those understood by PHP.
$_timezoneIdentifiers  : array<string|int, mixed>
A list of (Olson) timezone identifiers understood by PHP.
$_year  : int
Year
__construct()  : mixed
Builds a new date object. If $date contains date parts, use them to initialize the object.
__get()  : int|string
Getter for the date and time properties.
__isset()  : boolen
Returns whether a date or time property exists.
__set()  : mixed
Setter for the date and time properties.
__toString()  : string
Returns a simple string representation of the date object
add()  : mixed
Adds a number of seconds or units to this date, returning a new Date object.
after()  : bool
Returns whether this date is after the other.
before()  : bool
Returns whether this date is before the other.
compareDate()  : int
Compares this date to another date object to see which one is greater (later). Assumes that the dates are in the same timezone.
compareDateTime()  : int
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()  : int
Compares this to another date object by time, to see which one is greater (later). Assumes that the dates are in the same timezone.
datestamp()  : int
Returns the unix timestamp representation of this date, 12:00am.
dateString()  : string
Formats date and time to be passed around as a short url parameter.
dayOfWeek()  : int
Returns the day of the week (0 = Sunday, 6 = Saturday) of this date.
dayOfYear()  : int
Returns the day number of the year (1 to 365/366).
diff()  : int
Returns number of days between this date and another.
equals()  : bool
Returns whether this date is the same like the other.
format()  : string
Formats time using the specifiers available in date() or in the DateTime class' format() method.
fromDays()  : 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
Returns the normalized (Olson) timezone name of a timezone alias.
isValid()  : bool
Is the date currently represented by this object a valid date?
setDefaultFormat()  : mixed
Sets the default date format used in __toString()
setNthWeekday()  : mixed
Sets the date of this object to the $nth weekday of $weekday.
setTimezone()  : Horde_Date
Converts this object to a different timezone.
strftime()  : string
Formats date and time using strftime() format.
sub()  : mixed
Subtracts a number of seconds or units from this date, returning a new Horde_Date object.
timestamp()  : int
Returns the unix timestamp representation of this date.
toDateTime()  : DateTime
Returns a DateTime object representing this object.
toDays()  : int
Converts a date in the proleptic Gregorian calendar to the no of days since 24th November, 4714 B.C.
toiCalendar()  : string
Formats date and time to the RFC 2445 iCalendar DATE-TIME format.
toJson()  : string
Formats date and time to the ISO format used by JSON.
tzOffset()  : string
Returns the time offset for local time zone.
weekOfMonth()  : int
Returns the week of the month.
weekOfYear()  : int
Returns the week of the year, first Monday is first day of first week.
weeksInYear()  : int
Returns the number of weeks in the given year (52 or 53).
_correct()  : mixed
Corrects any over- or underflows in any of the date's members.
_correctMonth()  : mixed
Corrects the current month.
_initializeFromArgs()  : mixed
Handles args in order: year month day hour min sec tz
_initializeFromArray()  : mixed
_initializeFromObject()  : mixed
_initializeTimezone()  : mixed
_regexCallback()  : string
Callback used to replace a strtime pattern
_strftime()  : string
Formats date and time using a limited set of the strftime() format.

Constants

DATE_DEFAULT

public mixed DATE_DEFAULT = 'Y-m-d H:i:s'

DATE_FRIDAY

public mixed DATE_FRIDAY = 5

DATE_JSON

public mixed DATE_JSON = 'Y-m-d\\TH:i:s'

DATE_MONDAY

public mixed DATE_MONDAY = 1

DATE_SATURDAY

public mixed DATE_SATURDAY = 6

DATE_SUNDAY

public mixed DATE_SUNDAY = 0

DATE_THURSDAY

public mixed DATE_THURSDAY = 4

DATE_TUESDAY

public mixed DATE_TUESDAY = 2

DATE_WEDNESDAY

public mixed DATE_WEDNESDAY = 3

MASK_ALLDAYS

public mixed MASK_ALLDAYS = 127

MASK_ALLPARTS

public mixed MASK_ALLPARTS = 63

MASK_DAY

public mixed MASK_DAY = 8

MASK_FRIDAY

public mixed MASK_FRIDAY = 32

MASK_HOUR

public mixed MASK_HOUR = 4

MASK_MINUTE

public mixed MASK_MINUTE = 2

MASK_MONDAY

public mixed MASK_MONDAY = 2

MASK_MONTH

public mixed MASK_MONTH = 16

MASK_SATURDAY

public mixed MASK_SATURDAY = 64

MASK_SECOND

public mixed MASK_SECOND = 1

MASK_SUNDAY

public mixed MASK_SUNDAY = 1

MASK_THURSDAY

public mixed MASK_THURSDAY = 16

MASK_TUESDAY

public mixed MASK_TUESDAY = 4

MASK_WEDNESDAY

public mixed MASK_WEDNESDAY = 8

MASK_WEEKDAYS

public mixed MASK_WEEKDAYS = 62

MASK_WEEKEND

public mixed MASK_WEEKEND = 65

MASK_YEAR

public mixed MASK_YEAR = 32

Properties

$_corrections

Map of required correction masks.

protected static array<string|int, mixed> $_corrections = array('year' => self::MASK_YEAR, 'month' => self::MASK_MONTH, 'mday' => self::MASK_DAY, 'hour' => self::MASK_HOUR, 'min' => self::MASK_MINUTE, 'sec' => self::MASK_SECOND)
Tags
see
__set()

$_defaultFormat

Default format for __toString()

protected string $_defaultFormat = self::DATE_DEFAULT

$_defaultSpecs

Default specs that are always supported.

protected static string $_defaultSpecs = '-%CdDeHImMnRStTyY'

$_formatCache

protected mixed $_formatCache = array()

$_hour

Hour

protected int $_hour = 0

$_mday

Day

protected int $_mday

$_min

Minute

protected int $_min = 0

$_month

Month

protected int $_month

$_sec

Second

protected int $_sec = 0

$_supportedSpecs

Internally supported strftime() specifiers.

protected static string $_supportedSpecs = ''

$_timezone

String representation of the date's timezone.

protected string $_timezone

$_timezoneAbbreviations

These aliases map timezone abbreviations to those understood by PHP.

protected static array<string|int, mixed> $_timezoneAbbreviations = array()
Tags
todo

This list better moves somewhere else

see
getTimezoneAlias()

$_timezoneAliases

These aliases map Windows, Lotus, and other Timezone IDs to those understood by PHP.

protected static array<string|int, mixed> $_timezoneAliases = array( 'Dateline Standard Time' => 'Etc/GMT+12', 'UTC-11' => 'Etc/GMT+11', 'Hawaiian Standard Time' => 'Pacific/Honolulu', 'Alaskan Standard Time' => 'America/Anchorage', 'Pacific Standard Time (Mexico)' => 'America/Santa_Isabel', 'Pacific Standard Time' => 'America/Los_Angeles', 'US Mountain Standard Time' => 'America/Phoenix', 'Mountain Standard Time (Mexico)' => 'America/Chihuahua', 'Mountain Standard Time' => 'America/Denver', 'Central America Standard Time' => 'America/Guatemala', 'Central Standard Time' => 'America/Chicago', 'Central Standard Time (Mexico)' => 'America/Mexico_City', 'Canada Central Standard Time' => 'America/Regina', 'SA Pacific Standard Time' => 'America/Bogota', 'Eastern Standard Time' => 'America/New_York', 'US Eastern Standard Time' => 'America/Indianapolis', 'Venezuela Standard Time' => 'America/Caracas', 'Paraguay Standard Time' => 'America/Asuncion', 'Atlantic Standard Time' => 'America/Halifax', 'Central Brazilian Standard Time' => 'America/Cuiaba', 'SA Western Standard Time' => 'America/La_Paz', 'Pacific SA Standard Time' => 'America/Santiago', 'Newfoundland Standard Time' => 'America/St_Johns', 'E. South America Standard Time' => 'America/Sao_Paulo', 'Argentina Standard Time' => 'America/Buenos_Aires', 'SA Eastern Standard Time' => 'America/Cayenne', 'Greenland Standard Time' => 'America/Godthab', 'Montevideo Standard Time' => 'America/Montevideo', 'Bahia Standard Time' => 'America/Bahia', 'UTC-02' => 'Etc/GMT+2', 'Azores Standard Time' => 'Atlantic/Azores', 'Cape Verde Standard Time' => 'Atlantic/Cape_Verde', 'Morocco Standard Time' => 'Africa/Casablanca', 'GMT Standard Time' => 'Europe/London', 'Greenwich Standard Time' => 'Atlantic/Reykjavik', 'W. Europe Standard Time' => 'Europe/Berlin', 'Central Europe Standard Time' => 'Europe/Budapest', 'Romance Standard Time' => 'Europe/Paris', 'Central European Standard Time' => 'Europe/Warsaw', 'W. Central Africa Standard Time' => 'Africa/Lagos', 'Namibia Standard Time' => 'Africa/Windhoek', 'Jordan Standard Time' => 'Asia/Amman', 'GTB Standard Time' => 'Europe/Bucharest', 'Middle East Standard Time' => 'Asia/Beirut', 'Egypt Standard Time' => 'Africa/Cairo', 'Syria Standard Time' => 'Asia/Damascus', 'E. Europe Standard Time' => 'Asia/Nicosia', 'South Africa Standard Time' => 'Africa/Johannesburg', 'FLE Standard Time' => 'Europe/Kiev', 'Turkey Standard Time' => 'Europe/Istanbul', 'Israel Standard Time' => 'Asia/Jerusalem', 'Arabic Standard Time' => 'Asia/Baghdad', 'Kaliningrad Standard Time' => 'Europe/Kaliningrad', 'Arab Standard Time' => 'Asia/Riyadh', 'E. Africa Standard Time' => 'Africa/Nairobi', 'Iran Standard Time' => 'Asia/Tehran', 'Arabian Standard Time' => 'Asia/Dubai', 'Azerbaijan Standard Time' => 'Asia/Baku', 'Russian Standard Time' => 'Europe/Moscow', 'Mauritius Standard Time' => 'Indian/Mauritius', 'Georgian Standard Time' => 'Asia/Tbilisi', 'Caucasus Standard Time' => 'Asia/Yerevan', 'Afghanistan Standard Time' => 'Asia/Kabul', 'Pakistan Standard Time' => 'Asia/Karachi', 'West Asia Standard Time' => 'Asia/Tashkent', 'India Standard Time' => 'Asia/Calcutta', 'Sri Lanka Standard Time' => 'Asia/Colombo', 'Nepal Standard Time' => 'Asia/Katmandu', 'Central Asia Standard Time' => 'Asia/Almaty', 'Bangladesh Standard Time' => 'Asia/Dhaka', 'Ekaterinburg Standard Time' => 'Asia/Yekaterinburg', 'Myanmar Standard Time' => 'Asia/Rangoon', 'SE Asia Standard Time' => 'Asia/Bangkok', 'N. Central Asia Standard Time' => 'Asia/Novosibirsk', 'China Standard Time' => 'Asia/Shanghai', 'North Asia Standard Time' => 'Asia/Krasnoyarsk', 'Singapore Standard Time' => 'Asia/Singapore', 'W. Australia Standard Time' => 'Australia/Perth', 'Taipei Standard Time' => 'Asia/Taipei', 'Ulaanbaatar Standard Time' => 'Asia/Ulaanbaatar', 'North Asia East Standard Time' => 'Asia/Irkutsk', 'Tokyo Standard Time' => 'Asia/Tokyo', 'Korea Standard Time' => 'Asia/Seoul', 'Cen. Australia Standard Time' => 'Australia/Adelaide', 'AUS Central Standard Time' => 'Australia/Darwin', 'E. Australia Standard Time' => 'Australia/Brisbane', 'AUS Eastern Standard Time' => 'Australia/Sydney', 'West Pacific Standard Time' => 'Pacific/Port_Moresby', 'Tasmania Standard Time' => 'Australia/Hobart', 'Yakutsk Standard Time' => 'Asia/Yakutsk', 'Central Pacific Standard Time' => 'Pacific/Guadalcanal', 'Vladivostok Standard Time' => 'Asia/Vladivostok', 'New Zealand Standard Time' => 'Pacific/Auckland', 'UTC+12' => 'Etc/GMT-12', 'Fiji Standard Time' => 'Pacific/Fiji', 'Magadan Standard Time' => 'Asia/Magadan', 'Tonga Standard Time' => 'Pacific/Tongatapu', 'Samoa Standard Time' => 'Pacific/Apia', // Found from Lotus Notes 'W. Europe' => 'Europe/Berlin', 'E. Europe' => 'Asia/Nicosia', // Old Olsen names, from the "backward" file. 'Africa/Asmera' => 'Africa/Nairobi', 'Africa/Timbuktu' => 'Africa/Abidjan', 'America/Argentina/ComodRivadavia' => 'America/Argentina/Catamarca', 'America/Atka' => 'America/Adak', 'America/Buenos_Aires' => 'America/Argentina/Buenos_Aires', 'America/Catamarca' => 'America/Argentina/Catamarca', 'America/Coral_Harbour' => 'America/Atikokan', 'America/Cordoba' => 'America/Argentina/Cordoba', 'America/Ensenada' => 'America/Tijuana', 'America/Fort_Wayne' => 'America/Indiana/Indianapolis', 'America/Indianapolis' => 'America/Indiana/Indianapolis', 'America/Jujuy' => 'America/Argentina/Jujuy', 'America/Knox_IN' => 'America/Indiana/Knox', 'America/Louisville' => 'America/Kentucky/Louisville', 'America/Mendoza' => 'America/Argentina/Mendoza', 'America/Montreal' => 'America/Toronto', 'America/Porto_Acre' => 'America/Rio_Branco', 'America/Rosario' => 'America/Argentina/Cordoba', 'America/Santa_Isabel' => 'America/Tijuana', 'America/Shiprock' => 'America/Denver', 'America/Virgin' => 'America/Port_of_Spain', 'Antarctica/South_Pole' => 'Pacific/Auckland', 'Asia/Ashkhabad' => 'Asia/Ashgabat', 'Asia/Calcutta' => 'Asia/Kolkata', 'Asia/Chongqing' => 'Asia/Shanghai', 'Asia/Chungking' => 'Asia/Shanghai', 'Asia/Dacca' => 'Asia/Dhaka', 'Asia/Harbin' => 'Asia/Shanghai', 'Asia/Kashgar' => 'Asia/Urumqi', 'Asia/Katmandu' => 'Asia/Kathmandu', 'Asia/Macao' => 'Asia/Macau', 'Asia/Saigon' => 'Asia/Ho_Chi_Minh', 'Asia/Tel_Aviv' => 'Asia/Jerusalem', 'Asia/Thimbu' => 'Asia/Thimphu', 'Asia/Ujung_Pandang' => 'Asia/Makassar', 'Asia/Ulan_Bator' => 'Asia/Ulaanbaatar', 'Atlantic/Faeroe' => 'Atlantic/Faroe', 'Atlantic/Jan_Mayen' => 'Europe/Oslo', 'Australia/ACT' => 'Australia/Sydney', 'Australia/Canberra' => 'Australia/Sydney', 'Australia/LHI' => 'Australia/Lord_Howe', 'Australia/NSW' => 'Australia/Sydney', 'Australia/North' => 'Australia/Darwin', 'Australia/Queensland' => 'Australia/Brisbane', 'Australia/South' => 'Australia/Adelaide', 'Australia/Tasmania' => 'Australia/Hobart', 'Australia/Victoria' => 'Australia/Melbourne', 'Australia/West' => 'Australia/Perth', 'Australia/Yancowinna' => 'Australia/Broken_Hill', 'Brazil/Acre' => 'America/Rio_Branco', 'Brazil/DeNoronha' => 'America/Noronha', 'Brazil/East' => 'America/Sao_Paulo', 'Brazil/West' => 'America/Manaus', 'Canada/Atlantic' => 'America/Halifax', 'Canada/Central' => 'America/Winnipeg', 'Canada/East-Saskatchewan' => 'America/Regina', 'Canada/Eastern' => 'America/Toronto', 'Canada/Mountain' => 'America/Edmonton', 'Canada/Newfoundland' => 'America/St_Johns', 'Canada/Pacific' => 'America/Vancouver', 'Canada/Saskatchewan' => 'America/Regina', 'Canada/Yukon' => 'America/Whitehorse', 'Chile/Continental' => 'America/Santiago', 'Chile/EasterIsland' => 'Pacific/Easter', 'Cuba' => 'America/Havana', 'Egypt' => 'Africa/Cairo', 'Eire' => 'Europe/Dublin', 'Europe/Belfast' => 'Europe/London', 'Europe/Tiraspol' => 'Europe/Chisinau', 'GB' => 'Europe/London', 'GB-Eire' => 'Europe/London', 'GMT+0' => 'Etc/GMT', 'GMT-0' => 'Etc/GMT', 'GMT0' => 'Etc/GMT', 'Greenwich' => 'Etc/GMT', 'Hongkong' => 'Asia/Hong_Kong', 'Iceland' => 'Atlantic/Reykjavik', 'Iran' => 'Asia/Tehran', 'Israel' => 'Asia/Jerusalem', 'Jamaica' => 'America/Jamaica', 'Japan' => 'Asia/Tokyo', 'Kwajalein' => 'Pacific/Kwajalein', 'Libya' => 'Africa/Tripoli', 'Mexico/BajaNorte' => 'America/Tijuana', 'Mexico/BajaSur' => 'America/Mazatlan', 'Mexico/General' => 'America/Mexico_City', 'NZ' => 'Pacific/Auckland', 'NZ-CHAT' => 'Pacific/Chatham', 'Navajo' => 'America/Denver', 'PRC' => 'Asia/Shanghai', 'Pacific/Ponape' => 'Pacific/Pohnpei', 'Pacific/Samoa' => 'Pacific/Pago_Pago', 'Pacific/Truk' => 'Pacific/Chuuk', 'Pacific/Yap' => 'Pacific/Chuuk', 'Poland' => 'Europe/Warsaw', 'Portugal' => 'Europe/Lisbon', 'ROC' => 'Asia/Taipei', 'ROK' => 'Asia/Seoul', 'Singapore' => 'Asia/Singapore', 'Turkey' => 'Europe/Istanbul', 'UCT' => 'Etc/UCT', 'US/Alaska' => 'America/Anchorage', 'US/Aleutian' => 'America/Adak', 'US/Arizona' => 'America/Phoenix', 'US/Central' => 'America/Chicago', 'US/East-Indiana' => 'America/Indiana/Indianapolis', 'US/Eastern' => 'America/New_York', 'US/Hawaii' => 'Pacific/Honolulu', 'US/Indiana-Starke' => 'America/Indiana/Knox', 'US/Michigan' => 'America/Detroit', 'US/Mountain' => 'America/Denver', 'US/Pacific' => 'America/Los_Angeles', 'US/Samoa' => 'Pacific/Pago_Pago', 'UTC' => 'UTC', 'Universal' => 'UTC', 'W-SU' => 'Europe/Moscow', 'Zulu' => 'UTC', )
Tags
todo

This list better moves somewhere else

$_timezoneIdentifiers

A list of (Olson) timezone identifiers understood by PHP.

protected static array<string|int, mixed> $_timezoneIdentifiers = array()
Tags
todo

This list better moves somewhere else

see
getTimezoneAlias()

$_year

Year

protected int $_year

Methods

__construct()

Builds a new date object. If $date contains date parts, use them to initialize the object.

public __construct([mixed $date = null ][, mixed $timezone = null ]) : mixed

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.
Parameters
$date : mixed = null
$timezone : mixed = null
Tags
throws
Horde_Date_Exception
Return values
mixed

__get()

Getter for the date and time properties.

public __get(string $name) : int|string
Parameters
$name : string

One of 'year', 'month', 'mday', 'hour', 'min', 'sec' or 'timezone' (since Horde_Date 2.0.0).

Return values
int|string

The property value, or null if not set.

__isset()

Returns whether a date or time property exists.

public __isset(string $name) : boolen
Parameters
$name : string

One of 'year', 'month', 'mday', 'hour', 'min' or 'sec'.

Return values
boolen

True if the property exists and is set.

__set()

Setter for the date and time properties.

public __set(string $name, int|string $value) : mixed
Parameters
$name : string

One of 'year', 'month', 'mday', 'hour', 'min', 'sec' or 'timezone' (since Horde_Date 2.0.0).

$value : int|string

The property value.

Return values
mixed

__toString()

Returns a simple string representation of the date object

public __toString() : string
Return values
string

This object converted to a string.

add()

Adds a number of seconds or units to this date, returning a new Date object.

public add(mixed $factor) : mixed
Parameters
$factor : mixed
Return values
mixed

after()

Returns whether this date is after the other.

public after(mixed $other) : bool
Parameters
$other : mixed

The date to compare to.

Return values
bool

True if this date is after the other.

before()

Returns whether this date is before the other.

public before(mixed $other) : bool
Parameters
$other : mixed

The date to compare to.

Return values
bool

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) : int
Parameters
$other : mixed

The date to compare to.

Return values
int

== 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) : int
Parameters
$other : mixed

The date to compare to.

Return values
int

== 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) : int
Parameters
$other : mixed

The date to compare to.

Return values
int

== 0 if they are at the same time

= 1 if $this is greater (later) <= -1 if $other is greater (later)

datestamp()

Returns the unix timestamp representation of this date, 12:00am.

public datestamp() : int
Return values
int

A unix timestamp.

dateString()

Formats date and time to be passed around as a short url parameter.

public dateString() : string
Return values
string

Date and time.

dayOfWeek()

Returns the day of the week (0 = Sunday, 6 = Saturday) of this date.

public dayOfWeek() : int
Return values
int

The day of the week.

dayOfYear()

Returns the day number of the year (1 to 365/366).

public dayOfYear() : int
Return values
int

The day of the year.

diff()

Returns number of days between this date and another.

public diff(Horde_Date $other) : int
Parameters
$other : Horde_Date

The other day to diff with.

Return values
int

The absolute number of days between the two dates.

equals()

Returns whether this date is the same like the other.

public equals(mixed $other) : bool
Parameters
$other : mixed

The date to compare to.

Return values
bool

True if this date is the same like the other.

format()

Formats time using the specifiers available in date() or in the DateTime class' format() method.

public format(string $format) : string

To format in languages other than English, use strftime() instead.

Parameters
$format : string
Return values
string

Formatted time.

fromDays()

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.

public static fromDays(int $days) : Horde_Date

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

Parameters
$days : int

the number of days since 24th November, 4714 B.C.

Tags
author

Monte Ohrt monte@ispi.net

author

Pierre-Alain Joye pajoye@php.net

author

Daniel Convissor danielc@php.net

author

C.A. Woodcock c01234@netcomuk.co.uk

Return values
Horde_Date

A Horde_Date object representing the date.

getTimezoneAlias()

Returns the normalized (Olson) timezone name of a timezone alias.

public static getTimezoneAlias(string $timezone) : string

We currently support Windows and Lotus timezone names, and timezone abbreviations.

Parameters
$timezone : string

Some timezone alias.

Tags
since

Horde_Date 2.3.0

Return values
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() : bool
Return values
bool

Validity, counting leap years, etc.

setDefaultFormat()

Sets the default date format used in __toString()

public setDefaultFormat(string $format) : mixed
Parameters
$format : string
Return values
mixed

setNthWeekday()

Sets the date of this object to the $nth weekday of $weekday.

public setNthWeekday(int $weekday[, int $nth = 1 ]) : mixed
Parameters
$weekday : int

The day of the week (0 = Sunday, etc).

$nth : int = 1

The $nth $weekday to set to (defaults to 1). Negative values count from end of the month (@since Horde_Date 2.1.0).

Return values
mixed

setTimezone()

Converts this object to a different timezone.

public setTimezone(string $timezone) : Horde_Date
Parameters
$timezone : string

The new timezone.

Tags
throws
Horde_Date_Exception
Return values
Horde_Date

This object.

strftime()

Formats date and time using strftime() format.

public strftime(mixed $format) : string
Parameters
$format : mixed
Return values
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(mixed $factor) : mixed
Parameters
$factor : mixed
Return values
mixed

timestamp()

Returns the unix timestamp representation of this date.

public timestamp() : int
Return values
int

A unix timestamp.

toDateTime()

Returns a DateTime object representing this object.

public toDateTime() : DateTime
Return values
DateTime

toDays()

Converts a date in the proleptic Gregorian calendar to the no of days since 24th November, 4714 B.C.

public toDays() : int

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

Tags
author

Monte Ohrt monte@ispi.net

author

Pierre-Alain Joye pajoye@php.net

author

Daniel Convissor danielc@php.net

author

C.A. Woodcock c01234@netcomuk.co.uk

Return values
int

The number of days since 24th November, 4714 B.C.

toiCalendar()

Formats date and time to the RFC 2445 iCalendar DATE-TIME format.

public toiCalendar([bool $floating = false ]) : string
Parameters
$floating : bool = false

Whether to return a floating date-time (without time zone information).

Return values
string

Date and time.

toJson()

Formats date and time to the ISO format used by JSON.

public toJson() : string
Return values
string

Date and time.

tzOffset()

Returns the time offset for local time zone.

public tzOffset([bool $colon = true ]) : string
Parameters
$colon : bool = true

Place a colon between hours and minutes?

Return values
string

Timezone offset as a string in the format +HH:MM.

weekOfMonth()

Returns the week of the month.

public weekOfMonth() : int
Return values
int

The week number.

weekOfYear()

Returns the week of the year, first Monday is first day of first week.

public weekOfYear() : int
Return values
int

The week number.

weeksInYear()

Returns the number of weeks in the given year (52 or 53).

public static weeksInYear(int $year) : int
Parameters
$year : int

The year to count the number of weeks in.

Return values
int

$numWeeks The number of weeks in $year.

_correct()

Corrects any over- or underflows in any of the date's members.

protected _correct([int $mask = self::MASK_ALLPARTS ][, int $down = false ]) : mixed
Parameters
$mask : int = self::MASK_ALLPARTS

We may not want to correct some overflows.

$down : int = false

Whether to correct the date up or down.

Return values
mixed

_correctMonth()

Corrects the current month.

protected _correctMonth() : mixed

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

Return values
mixed

_initializeFromArgs()

Handles args in order: year month day hour min sec tz

protected _initializeFromArgs(mixed $args) : mixed
Parameters
$args : mixed
Return values
mixed

_initializeFromArray()

protected _initializeFromArray(mixed $date) : mixed
Parameters
$date : mixed
Return values
mixed

_initializeFromObject()

protected _initializeFromObject(mixed $date) : mixed
Parameters
$date : mixed
Return values
mixed

_initializeTimezone()

protected _initializeTimezone(mixed $timezone) : mixed
Parameters
$timezone : mixed
Return values
mixed

_regexCallback()

Callback used to replace a strtime pattern

protected _regexCallback(mixed $reg) : string
Parameters
$reg : mixed
Return values
string

Replacement string.

_strftime()

Formats date and time using a limited set of the strftime() format.

protected _strftime(mixed $format) : string
Parameters
$format : mixed
Return values
string

strftime() formatted date and time.

Search results