Date.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
LICENSE This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Date  
Version
$Id$  

\Zend_Date

Package: Zend_Date\Zend_Date_DateObject
Parent(s)
\Zend_Date_DateObject
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  DAY = 'dd'
>VConstant  DAY_SHORT = 'd'
>VConstant  DAY_SUFFIX = 'SS'
>VConstant  DAY_OF_YEAR = 'D'
>VConstant  WEEKDAY = 'EEEE'
>VConstant  WEEKDAY_SHORT = 'EEE'
>VConstant  WEEKDAY_NARROW = 'E'
>VConstant  WEEKDAY_NAME = 'EE'
>VConstant  WEEKDAY_8601 = 'eee'
>VConstant  WEEKDAY_DIGIT = 'e'
>VConstant  WEEK = 'ww'
>VConstant  MONTH = 'MM'
>VConstant  MONTH_SHORT = 'M'
>VConstant  MONTH_DAYS = 'ddd'
>VConstant  MONTH_NAME = 'MMMM'
>VConstant  MONTH_NAME_SHORT = 'MMM'
>VConstant  MONTH_NAME_NARROW = 'MMMMM'
>VConstant  YEAR = 'y'
>VConstant  YEAR_SHORT = 'yy'
>VConstant  YEAR_8601 = 'Y'
>VConstant  YEAR_SHORT_8601 = 'YY'
>VConstant  LEAPYEAR = 'l'
>VConstant  MERIDIEM = 'a'
>VConstant  SWATCH = 'B'
>VConstant  HOUR = 'HH'
>VConstant  HOUR_SHORT = 'H'
>VConstant  HOUR_AM = 'hh'
>VConstant  HOUR_SHORT_AM = 'h'
>VConstant  MINUTE = 'mm'
>VConstant  MINUTE_SHORT = 'm'
>VConstant  SECOND = 'ss'
>VConstant  SECOND_SHORT = 's'
>VConstant  MILLISECOND = 'S'
>VConstant  TIMEZONE_NAME = 'zzzz'
>VConstant  DAYLIGHT = 'I'
>VConstant  GMT_DIFF = 'Z'
>VConstant  GMT_DIFF_SEP = 'ZZZZ'
>VConstant  TIMEZONE = 'z'
>VConstant  TIMEZONE_SECS = 'X'
>VConstant  ISO_8601 = 'c'
>VConstant  RFC_2822 = 'r'
>VConstant  TIMESTAMP = 'U'
>VConstant  ERA = 'G'
>VConstant  ERA_NAME = 'GGGG'
>VConstant  ERA_NARROW = 'GGGGG'
>VConstant  DATES = 'F'
>VConstant  DATE_FULL = 'FFFFF'
>VConstant  DATE_LONG = 'FFFF'
>VConstant  DATE_MEDIUM = 'FFF'
>VConstant  DATE_SHORT = 'FF'
>VConstant  TIMES = 'WW'
>VConstant  TIME_FULL = 'TTTTT'
>VConstant  TIME_LONG = 'TTTT'
>VConstant  TIME_MEDIUM = 'TTT'
>VConstant  TIME_SHORT = 'TT'
>VConstant  DATETIME = 'K'
>VConstant  DATETIME_FULL = 'KKKKK'
>VConstant  DATETIME_LONG = 'KKKK'
>VConstant  DATETIME_MEDIUM = 'KKK'
>VConstant  DATETIME_SHORT = 'KK'
>VConstant  ATOM = 'OOO'
>VConstant  COOKIE = 'CCC'
>VConstant  RFC_822 = 'R'
>VConstant  RFC_850 = 'RR'
>VConstant  RFC_1036 = 'RRR'
>VConstant  RFC_1123 = 'RRRR'
>VConstant  RFC_3339 = 'RRRRR'
>VConstant  RSS = 'SSS'
>VConstant  W3C = 'WWW'

Properties

>VPropertyprivate$_fractional = 0
Default value0Details
Type
n/a
>VPropertyprivate$_locale = null
Default valuenullDetails
Type
n/a
>VPropertyprivate$_options = array('format_type' => 'iso', 'fix_dst' => true, 'extend_month' => false, 'cache' => null, 'timesync' => null)
static
Default valuearray('format_type' => 'iso', 'fix_dst' => true, 'extend_month' => false, 'cache' => null, 'timesync' => null)Details
Type
n/a
>VPropertyprivate$_precision = 3
Default value3Details
Type
n/a

Methods

methodpublic__construct(string | integer | \Zend_Date | array $date = null, string $part = null, string | \Zend_Locale $locale = null) : \Zend_Date

Generates the standard date object, could be a unix timestamp, localized date, string, integer, array and so on. Also parts of dates or time are supported Always set the default timezone: http://php.net/date_default_timezone_set For example, in your bootstrap: date_default_timezone_set('America/Los_Angeles'); For detailed instructions please look in the docu.

Parameters
NameTypeDescription
$datestring | integer | \Zend_Date | array

OPTIONAL Date value or value of date part to set

                                            ,depending on $part. If null the actual time is set
$partstring

OPTIONAL Defines the input format of $date

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublic__toString() : string

Returns a string representation of the date which is equal with the timestamp

Returns
TypeDescription
string
methodprivate_assign(string $calc, string | integer $date, string | integer $comp = 0, boolean | integer $dst = false) : integer | string | \Zend_Date

Calculates the date or object

Parameters
NameTypeDescription
$calcstring

Calculation to make

$datestring | integer

Date for calculation

$compstring | integer

Second date for calculation

$dstboolean | integer

Use dst correction if option is set

Returns
TypeDescription
integer | string | \Zend_Datenew timestamp or Zend_Date depending on calculation
methodprivate_calcdetail(string $calc, string | integer | array | \Zend_Date $date,  $type, string | \Zend_Locale $locale) : integer | string

Calculate date details

Parameters
NameTypeDescription
$calcstring

Calculation to make

$datestring | integer | array | \Zend_Date

Date or Part to calculate

$type
$localestring | \Zend_Locale

Locale for parsing input

Returns
TypeDescription
integer | stringnew date
Throws
ExceptionDescription
\Zend_Date_Exception
methodprivate_calculate(string $calc, string | integer | array | \Zend_Date $date, string $part, string | \Zend_Locale $locale) : integer | string | \Zend_Date

Calculates the date or object

Parameters
NameTypeDescription
$calcstring

Calculation to make, one of: 'add'|'sub'|'cmp'|'copy'|'set'

$datestring | integer | array | \Zend_Date

Date or datepart to calculate with

$partstring

Part of the date to calculate, if null the timestamp is used

$localestring | \Zend_Locale

Locale for parsing input

Returns
TypeDescription
integer | string | \Zend_Datenew timestamp
Throws
ExceptionDescription
\Zend_Date_Exception
methodprivate_calcvalue(string $calc, string | integer | \Zend_Date $value,  $type,  $parameter, string | \Zend_Locale $locale) : integer | \Zend_Date

Internal calculation, returns the requested date type

Parameters
NameTypeDescription
$calcstring

Calculation to make

$valuestring | integer | \Zend_Date

Datevalue to calculate with, if null the actual value is taken

$type
$parameter
$localestring | \Zend_Locale

Locale for parsing input

Returns
TypeDescription
integer | \Zend_Datenew date
Throws
ExceptionDescription
\Zend_Date_Exception
methodprivate_checkLocation(array $location) : \$horizon

Check if location is supported

Parameters
NameTypeDescription
$locationarray

locations array

Returns
TypeDescription
\$horizonfloat
methodprivate_date(string $calc, string | integer | array | \Zend_Date $date, string $format, string | \Zend_Locale $locale) : integer | \Zend_Date

Returns the calculated date

Parameters
NameTypeDescription
$calcstring

Calculation to make

$datestring | integer | array | \Zend_Date

Date to calculate with, if null the actual date is taken

$formatstring

Date format for parsing

$localestring | \Zend_Locale

Locale for parsing input

Returns
TypeDescription
integer | \Zend_Datenew date
Throws
ExceptionDescription
\Zend_Date_Exception
methodprivate_day(string $calc, \Zend_Date $day, \Zend_Locale $locale) : \Zend_Date | integer

Returns the calculated day

Parameters
NameTypeDescription
$calcstring

Type of calculation to make

$day\Zend_Date

Day to calculate, when null the actual day is calculated

$locale\Zend_Locale

Locale for parsing input

Returns
TypeDescription
\Zend_Date | integer
methodprivate_getDigitFromName(string $name) : integer

Return digit from standard names (english) Faster implementation than locale aware searching

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
integerNumber of this month
Throws
ExceptionDescription
\Zend_Date_Exception
methodprotected_getLocalizedToken(string $token, string $locale) : string
static

Returns the ISO Token for all localized constants

Parameters
NameTypeDescription
$tokenstring

Token to normalize

$localestring

Locale to search

Returns
TypeDescription
string
methodprivate_month(string $calc, string | integer | array | \Zend_Date $month, string | \Zend_Locale $locale) : integer | \Zend_Date

Returns the calculated month

Parameters
NameTypeDescription
$calcstring

Calculation to make

$monthstring | integer | array | \Zend_Date

Month to calculate with, if null the actual month is taken

$localestring | \Zend_Locale

Locale for parsing input

Returns
TypeDescription
integer | \Zend_Datenew time
Throws
ExceptionDescription
\Zend_Date_Exception
methodprivate_parseIsoToDate(string $token, string $locale) : string

Internal parsing method

Parameters
NameTypeDescription
$tokenstring
$localestring
Returns
TypeDescription
string
methodprivate_time(string $calc, string | integer | array | \Zend_Date $time, string $format, string | \Zend_Locale $locale) : integer | \Zend_Date

Returns the calculated time

Parameters
NameTypeDescription
$calcstring

Calculation to make

$timestring | integer | array | \Zend_Date

Time to calculate with, if null the actual time is taken

$formatstring

Timeformat for parsing input

$localestring | \Zend_Locale

Locale for parsing input

Returns
TypeDescription
integer | \Zend_Datenew time
Throws
ExceptionDescription
\Zend_Date_Exception
methodprivate_timestamp(string $calc, string | integer | array | \Zend_Date $stamp) : \Zend_Date | integer

Returns the calculated timestamp HINT: timestamps are always GMT

Parameters
NameTypeDescription
$calcstring

Type of calculation to make

$stampstring | integer | array | \Zend_Date

Timestamp to calculate, when null the actual timestamp is calculated

Returns
TypeDescription
\Zend_Date | integer
Throws
ExceptionDescription
\Zend_Date_Exception
methodprivate_toComment(string $token) : string

Private function to make a comment of a token

Parameters
NameTypeDescription
$tokenstring
Returns
TypeDescription
string
methodprivate_toToken(string $part, string $locale) : string

Internal method to apply tokens

Parameters
NameTypeDescription
$partstring
$localestring
Returns
TypeDescription
string
methodprivate_weekday(string $calc, \Zend_Date $weekday, \Zend_Locale $locale) : \Zend_Date | integer

Returns the calculated weekday

Parameters
NameTypeDescription
$calcstring

Type of calculation to make

$weekday\Zend_Date

Weekday to calculate, when null the actual weekday is calculated

$locale\Zend_Locale

Locale for parsing input

Returns
TypeDescription
\Zend_Date | integer
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicadd(string | integer | array | \Zend_Date $date, string $part = self::TIMESTAMP, string | \Zend_Locale $locale = null) : \Zend_Date

Adds a date or datepart to the existing date, by extracting $part from $date, and modifying this object by adding that part. The $part is then extracted from this object and returned as an integer or numeric string (for large values, or $part's corresponding to pre-defined formatted date strings).

This could be for example a ISO 8601 date, the hour the monthname or only the minute. There are about 50 different supported date parts. For a complete list of supported datepart values look into the docu.
Parameters
NameTypeDescription
$datestring | integer | array | \Zend_Date

Date or datepart to add

$partstring

OPTIONAL Part of the date to add, if null the timestamp is added

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddArpa(string | integer | \Zend_Date $date, string | \Zend_Locale $locale = null) : \Zend_Date

Adds a RFC 822 date to the date object.

ARPA messages are used in emails or HTTP Headers. Only RFC 822 compilant date strings are accepted. For example: Sat, 14 Feb 09 00:31:30 +0100 Returned is the new date object
Parameters
NameTypeDescription
$datestring | integer | \Zend_Date

RFC 822 Date to add

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddDate(string | integer | array | \Zend_Date $date, string $format = null, string | \Zend_Locale $locale = null) : \Zend_Date

Adds a date to the existing date object. Format defines how to parse the date string.

If only parts are given the other parts are set to 0. If no format is given, the standardformat of this locale is used. For example: MM.dd.YYYY -> 10 -> +10 months
Parameters
NameTypeDescription
$datestring | integer | array | \Zend_Date

Date to add

$formatstring

OPTIONAL Date format for parsing input

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddDay( $day, string | \Zend_Locale $locale = null) : \Zend_Date

Adds days to the existing date object.

The day can be a number or a string. Adding days lower then 0 or greater than the number of this months days will result in adding or subtracting the relevant month. If a localized dayname is given it will be parsed with the default locale or the optional set locale.
Parameters
NameTypeDescription
$day
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddDayOfYear(string | integer | array | \Zend_Date $day, string | \Zend_Locale $locale = null) : \Zend_Date

Adds a day of year to the existing date object.

The day of year is always a number. Returned is the new date object Example: addDayOfYear(10); will add 10 days to the existing date object.
Parameters
NameTypeDescription
$daystring | integer | array | \Zend_Date

Day of Year to add

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddHour(string | integer | array | \Zend_Date $hour, string | \Zend_Locale $locale = null) : \Zend_Date

Adds hours to the existing date object.

The hour is always a number. Returned is the new date object Example: 04.May.1993 13:07:25 -> addHour(12); -> 05.May.1993 01:07:25
Parameters
NameTypeDescription
$hourstring | integer | array | \Zend_Date

Hour to add

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddIso(string | integer | \Zend_Date $date, string | \Zend_Locale $locale = null) : \Zend_Date

Adds a ISO date to the date object. Not given parts are set to default.

Only supported ISO 8601 formats are accepted. For example: 050901 -> + 01.Sept.2005 00:00:00, 10:00:00 -> +10h Returned is the new date object
Parameters
NameTypeDescription
$datestring | integer | \Zend_Date

ISO Date to add

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddMilliSecond(integer | \Zend_Date $milli = null, integer $precision = null) : \Zend_Date

Adds milliseconds to the date object

Parameters
NameTypeDescription
$milliinteger | \Zend_Date

(Optional) Millisecond to add, when null the actual millisecond is added

$precisioninteger

(Optional) Fractional precision for the given milliseconds

Returns
TypeDescription
\Zend_DateProvides fluid interface
methodpublicaddMinute(string | integer | array | \Zend_Date $minute, string | \Zend_Locale $locale = null) : \Zend_Date

Adds minutes to the existing date object.

The minute is always a number. Returned is the new date object Example: 04.May.1993 13:07:25 -> addMinute(65); -> 04.May.1993 13:12:25
Parameters
NameTypeDescription
$minutestring | integer | array | \Zend_Date

Minute to add

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddMonth(string | integer | array | \Zend_Date $month, string | \Zend_Locale $locale = null) : \Zend_Date

Adds months to the existing date object.

The month can be a number or a string. Adding months lower then 0 and greater then 12 will result in adding or subtracting the relevant year. (12 months equal one year) If a localized monthname is given it will be parsed with the default locale or the optional set locale. Returned is the new date object
Parameters
NameTypeDescription
$monthstring | integer | array | \Zend_Date

Month to add

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddSecond(string | integer | array | \Zend_Date $second, string | \Zend_Locale $locale = null) : \Zend_Date

Adds seconds to the existing date object.

The second is always a number. Returned is the new date object Example: 04.May.1993 13:07:25 -> addSecond(65); -> 04.May.1993 13:08:30
Parameters
NameTypeDescription
$secondstring | integer | array | \Zend_Date

Second to add

$localestring | \Zend_Locale

(Optional) Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddTime(string | integer | array | \Zend_Date $time, string $format = null, string | \Zend_Locale $locale = null) : \Zend_Date

Adds a time to the existing date. Format defines how to parse the time string.

If only parts are given the other parts are set to 0. If no format is given, the standardformat of this locale is used. For example: HH:mm:ss -> 10 -> +10 hours
Parameters
NameTypeDescription
$timestring | integer | array | \Zend_Date

Time to add

$formatstring

OPTIONAL Timeformat for parsing input

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddTimestamp(integer | string | array | \Zend_Date $timestamp) : \Zend_Date

Adds a timestamp

Parameters
NameTypeDescription
$timestampinteger | string | array | \Zend_Date

Timestamp to add

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddWeek(string | integer | array | \Zend_Date $week, string | \Zend_Locale $locale = null) : \Zend_Date

Adds a week. The week is always a number. The day of week is not changed.

Returned is the new date object Example: 09.Jan.2007 13:07:25 -> addWeek(1); -> 16.Jan.2007 13:07:25
Parameters
NameTypeDescription
$weekstring | integer | array | \Zend_Date

Week to add

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddWeekday( $weekday, string | \Zend_Locale $locale = null) : \Zend_Date

Adds weekdays to the existing date object.

The weekday can be a number or a string. If a localized dayname is given it will be parsed with the default locale or the optional set locale. Returned is the new date object Example: addWeekday(3); will add the difference of days from the begining of the month until wednesday.
Parameters
NameTypeDescription
$weekday
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicaddYear( $year, string | \Zend_Locale $locale = null) : \Zend_Date

Adds the year to the existing date object If the year is between 0 and 69, 2000 will be added (2000-2069) If the year if between 70 and 99, 1999 will be added (1970-1999) 3 or 4 digit years are added as expected. If you need to add years from 0-99 use add() instead.

Returned is the new date object
Parameters
NameTypeDescription
$year
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccheckLeapYear(integer | array | \Zend_Date $year) : boolean
static

Check a given year for leap year.

Parameters
NameTypeDescription
$yearinteger | array | \Zend_Date

Year to check

Returns
TypeDescription
boolean
methodpubliccompare(string | integer | array | \Zend_Date $date, string $part = self::TIMESTAMP, string | \Zend_Locale $locale = null) : integer

Compares a date or datepart with the existing one.

Returns -1 if earlier, 0 if equal and 1 if later.
Parameters
NameTypeDescription
$datestring | integer | array | \Zend_Date

Date or datepart to compare with the date object

$partstring

OPTIONAL Part of the date to compare, if null the timestamp is subtracted

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareArpa(string | integer | \Zend_Date $date, string | \Zend_Locale $locale = null) : integer

Compares a RFC 822 compilant date with the date object.

ARPA messages are used in emails or HTTP Headers. Only RFC 822 compilant date strings are accepted. For example: Sat, 14 Feb 09 00:31:30 +0100 Returns if equal, earlier or later
Parameters
NameTypeDescription
$datestring | integer | \Zend_Date

RFC 822 Date to sub

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareDate(string | integer | array | \Zend_Date $date, string $format = null, string | \Zend_Locale $locale = null) : integer

Compares the date from the existing date object, ignoring the time.

Format defines how to parse the date string. If only parts are given the other parts are set to 0. If no format is given, the standardformat of this locale is used. For example: 10.01.2000 => 10.02.1999 -> false
Parameters
NameTypeDescription
$datestring | integer | array | \Zend_Date

Date to compare

$formatstring

OPTIONAL Date format for parsing input

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareDay(string | integer | array | \Zend_Date $day, string | \Zend_Locale $locale = null) : integer

Compares the day with the existing date object, ignoring other date parts.

For example: 'Monday', 'en' -> 08.Jan.2007 -> 0 Returns if equal, earlier or later
Parameters
NameTypeDescription
$daystring | integer | array | \Zend_Date

Day to compare

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareDayOfYear(string | integer | array | \Zend_Date $day, string | \Zend_Locale $locale = null) : integer

Compares the day of year with the existing date object.

For example: compareDayOfYear(33) -> 02.Feb.2007 -> 0 Returns if equal, earlier or later
Parameters
NameTypeDescription
$daystring | integer | array | \Zend_Date

Day of Year to compare

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareHour(string | integer | array | \Zend_Date $hour, string | \Zend_Locale $locale = null) : integer

Compares the hour with the existing date object.

For example: 10:30:25 -> compareHour(10) -> 0 Returns if equal, earlier or later
Parameters
NameTypeDescription
$hourstring | integer | array | \Zend_Date

Hour to compare

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareIso(string | integer | \Zend_Date $date, string | \Zend_Locale $locale = null) : integer

Compares a ISO date with the date object. Not given parts are set to default.

Only supported ISO 8601 formats are accepted. For example: 050901 -> - 01.Sept.2005 00:00:00, 10:00:00 -> -10h Returns if equal, earlier or later
Parameters
NameTypeDescription
$datestring | integer | \Zend_Date

ISO Date to sub

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareMilliSecond(integer | \Zend_Date $milli = null, integer $precision = null) : integer

Compares only the millisecond part, returning the difference

Parameters
NameTypeDescription
$milliinteger | \Zend_Date

OPTIONAL Millisecond to compare, when null the actual millisecond is compared

$precisioninteger

OPTIONAL Fractional precision for the given milliseconds

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_ExceptionOn invalid input
methodpubliccompareMinute(string | integer | array | \Zend_Date $minute, string | \Zend_Locale $locale = null) : integer

Compares the minute with the existing date object.

For example: 10:30:25 -> compareMinute(30) -> 0 Returns if equal, earlier or later
Parameters
NameTypeDescription
$minutestring | integer | array | \Zend_Date

Hour to compare

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareMonth(string | integer | array | \Zend_Date $month, string | \Zend_Locale $locale = null) : integer

Compares the month with the existing date object, ignoring other date parts.

For example: 10.03.2000 -> 15.03.1950 -> true Returns if equal, earlier or later
Parameters
NameTypeDescription
$monthstring | integer | array | \Zend_Date

Month to compare

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareSecond(string | integer | array | \Zend_Date $second, string | \Zend_Locale $locale = null) : integer

Compares the second with the existing date object.

For example: 10:30:25 -> compareSecond(25) -> 0 Returns if equal, earlier or later
Parameters
NameTypeDescription
$secondstring | integer | array | \Zend_Date

Second to compare

$localestring | \Zend_Locale

(Optional) Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareTime(string | integer | array | \Zend_Date $time, string $format = null, string | \Zend_Locale $locale = null) : integer

Compares the time from the existing date. Format defines how to parse the time string.

If only parts are given the other parts are set to default. If no format us given, the standardformat of this locale is used. For example: HH:mm:ss -> 10 -> 10 hours
Parameters
NameTypeDescription
$timestring | integer | array | \Zend_Date

Time to compare

$formatstring

OPTIONAL Timeformat for parsing input

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareTimestamp(integer | string | array | \Zend_Date $timestamp) : integer

Compares two timestamps, returning the difference as integer

Parameters
NameTypeDescription
$timestampinteger | string | array | \Zend_Date

Timestamp to compare

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareWeek(string | integer | array | \Zend_Date $week, string | \Zend_Locale $locale = null) : integer

Compares only the week part, returning the difference Returned is the new date object Returns if equal, earlier or later Example: 09.Jan.2007 13:07:25 -> compareWeek(2); -> 0

Parameters
NameTypeDescription
$weekstring | integer | array | \Zend_Date

Week to compare

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
methodpubliccompareWeekday(string | integer | array | \Zend_Date $weekday, string | \Zend_Locale $locale = null) : integer

Compares the weekday with the existing date object, ignoring other date parts.

For example: 'Monday', 'en' -> 08.Jan.2007 -> 0 Returns if equal, earlier or later
Parameters
NameTypeDescription
$weekdaystring | integer | array | \Zend_Date

Weekday to compare

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccompareYear(string | integer | array | \Zend_Date $year, string | \Zend_Locale $locale = null) : integer

Compares the year with the existing date object, ignoring other date parts.

For example: 10.03.2000 -> 15.02.2000 -> true Returns if equal, earlier or later
Parameters
NameTypeDescription
$yearstring | integer | array | \Zend_Date

Year to compare

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
integer0 = equal, 1 = later, -1 = earlier
Throws
ExceptionDescription
\Zend_Date_Exception
methodpubliccopyPart(string $part, string | \Zend_Locale $locale = null) : \Zend_Date

Returns a new instance of Zend_Date with the selected part copied.

To make an exact copy, use PHP's clone keyword. For a complete list of supported date part values look into the docu. If a date part is copied, all other date parts are set to standard values. For example: If only YEAR is copied, the returned date object is equal to 01-01-YEAR 00:00:00 (01-01-1970 00:00:00 is equal to timestamp 0) If only HOUR is copied, the returned date object is equal to 01-01-1970 HOUR:00:00 (so $this contains a timestamp equal to a timestamp of 0 plus HOUR).
Parameters
NameTypeDescription
$partstring

Part of the date to compare, if null the timestamp is subtracted

$localestring | \Zend_Locale

OPTIONAL New object's locale. No adjustments to timezone are made.

Returns
TypeDescription
\Zend_DateNew clone with requested part
methodpublicequals(string | integer | array | \Zend_Date $date, string $part = self::TIMESTAMP, string | \Zend_Locale $locale = null) : boolean

Returns true when both date objects or date parts are equal.

For example: 15.May.2000 <-> 15.June.2000 Equals only for Day or Year... all other will return false
Parameters
NameTypeDescription
$datestring | integer | array | \Zend_Date

Date or datepart to equal with

$partstring

OPTIONAL Part of the date to compare, if null the timestamp is used

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
boolean
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicget(string $part = null, string | \Zend_Locale $locale = null) : string

Returns a representation of a date or datepart This could be for example a localized monthname, the time without date, the era or only the fractional seconds. There are about 50 different supported date parts.

For a complete list of supported datepart values look into the docu
Parameters
NameTypeDescription
$partstring

OPTIONAL Part of the date to return, if null the timestamp is returned

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
stringdate or datepart
methodpublicgetArpa(string | \Zend_Locale $locale = null) : string

Returns a RFC 822 compilant datestring from the date object.

This function does not return the RFC date as object. Use copy() instead.
Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
string
methodpublicgetDate(string | \Zend_Locale $locale = null) : \Zend_Date

Returns a clone of $this, with the time part set to 00:00:00.

Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
methodpublicgetDay(\Zend_Locale $locale = null) : \Zend_Date

Returns the day as new date object Example: 20.May.1986 -> 20.Jan.1970 00:00:00

Parameters
NameTypeDescription
$locale\Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
methodpublicgetDayOfYear(string | \Zend_Locale $locale = null) : \Zend_Date

Returns the day of year as new date object Example: 02.Feb.1986 10:00:00 -> 02.Feb.1970 00:00:00

Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
methodpublicgetFractionalPrecision() : integer

Returns the precision for fractional seconds

Returns
TypeDescription
integer
methodpublicgetFullYear(integer $value) : integer
static

Counts the exact year number < 70 - 2000 added, >70 < 100 - 1900, others just returned

Parameters
NameTypeDescription
$valueinteger

year number

Returns
TypeDescription
integerNumber of year
methodpublicgetHour(\Zend_Locale $locale = null) : \Zend_Date

Returns the hour as new date object Example: 02.Feb.1986 10:30:25 -> 01.Jan.1970 10:00:00

Parameters
NameTypeDescription
$locale\Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
methodpublicgetIso(string | \Zend_Locale $locale = null) : string

Returns the full ISO 8601 date from the date object.

Always the complete ISO 8601 specifiction is used. If an other ISO date is needed (ISO 8601 defines several formats) use toString() instead. This function does not return the ISO date as object. Use copy() instead.
Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
string
methodpublicgetLocale() : string

Returns the actual set locale

Returns
TypeDescription
string
methodpublicgetMilliSecond() : string

Returns the milliseconds of the date object

Returns
TypeDescription
string
methodpublicgetMinute(string | \Zend_Locale $locale = null) : \Zend_Date

Returns the minute as new date object Example: 02.Feb.1986 10:30:25 -> 01.Jan.1970 00:30:00

Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
methodpublicgetMonth(string | \Zend_Locale $locale = null) : \Zend_Date

Returns only the month from the date object as new object.

For example: 10.May.2000 10:30:00 -> 01.May.1970 00:00:00
Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
methodpublicgetSecond(string | \Zend_Locale $locale = null) : \Zend_Date

Returns the second as new date object Example: 02.Feb.1986 10:30:25 -> 01.Jan.1970 00:00:25

Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
methodpublicgetSunInfo(array $location) : array

Returns an array with the sunset and sunrise dates for all horizon types For a list of cities and correct locations use the class Zend_Date_Cities

Parameters
NameTypeDescription
$locationarray

location of suninfo

              ['horizon']   -> civil, nautic, astronomical, effective (default)
              ['longitude'] -> longitude of location
              ['latitude']  -> latitude of location
Returns
TypeDescription
array- [sunset|sunrise][effective|civil|nautic|astronomic]
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicgetSunrise(array $location) : \Zend_Date

Returns the time of sunrise for this date and a given location as new date object For a list of cities and correct locations use the class Zend_Date_Cities

Parameters
NameTypeDescription
$locationarray

location of sunrise

              ['horizon']   -> civil, nautic, astronomical, effective (default)
              ['longitude'] -> longitude of location
              ['latitude']  -> latitude of location
Returns
TypeDescription
\Zend_Date
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicgetSunset(array $location) : \Zend_Date

Returns the time of sunset for this date and a given location as new date object For a list of cities and correct locations use the class Zend_Date_Cities

Parameters
NameTypeDescription
$locationarray

location of sunset

              ['horizon']   -> civil, nautic, astronomical, effective (default)
              ['longitude'] -> longitude of location
              ['latitude']  -> latitude of location
Returns
TypeDescription
\Zend_Date
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicgetTime(string | \Zend_Locale $locale = null) : \Zend_Date

Returns only the time of the date as new Zend_Date object For example: 15.May.2000 10:11:23 will return a dateobject equal to 01.Jan.1970 10:11:23

Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
methodpublicgetTimestamp() : integer | string

Returns this object's internal UNIX timestamp (equivalent to Zend_Date::TIMESTAMP).

If the timestamp is too large for integers, then the return value will be a string. This function does not return the timestamp as an object. Use clone() or copyPart() instead.
Returns
TypeDescription
integer | stringUNIX timestamp
methodpublicgetTimezoneFromString(string $zone) : integer

Internal function, returns the offset of a given timezone

Parameters
NameTypeDescription
$zonestring
Returns
TypeDescription
integer
methodpublicgetWeek(\Zend_Locale $locale = null) : \Zend_Date

Returns the week as new date object using monday as begining of the week Example: 12.Jan.2007 -> 08.Jan.1970 00:00:00

Parameters
NameTypeDescription
$locale\Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
methodpublicgetWeekday(\Zend_Locale $locale = null) : \Zend_Date

Returns the weekday as new date object Weekday is always from 1-7 Example: 09-Jan-2007 -> 2 = Tuesday -> 02-Jan-1970 (when 02.01.1970 is also Tuesday)

Parameters
NameTypeDescription
$locale\Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
methodpublicgetYear(string | \Zend_Locale $locale = null) : \Zend_Date

Returns only the year from the date object as new object.

For example: 10.May.2000 10:30:00 -> 01.Jan.2000 00:00:00
Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
methodpublicisDate(string | array | \Zend_Date $date, string $format = null, string | \Zend_Locale $locale = null) : boolean
static

Checks if the given date is a real date or datepart.

Returns false if a expected datepart is missing or a datepart exceeds its possible border. But the check will only be done for the expected dateparts which are given by format. If no format is given the standard dateformat for the actual locale is used. f.e. 30.February.2007 will return false if format is 'dd.MMMM.YYYY'
Parameters
NameTypeDescription
$datestring | array | \Zend_Date

Date to parse for correctness

$formatstring

(Optional) Format for parsing the date string

$localestring | \Zend_Locale

(Optional) Locale for parsing date parts

Returns
TypeDescription
booleanTrue when all date parts are correct
methodpublicisEarlier(string | integer | array | \Zend_Date $date, string $part = null, string | \Zend_Locale $locale = null) : boolean

Returns if the given date or datepart is earlier For example: 15.May.2000 <-> 13.June.1999 will return true for day, year and date, but not for month

Parameters
NameTypeDescription
$datestring | integer | array | \Zend_Date

Date or datepart to compare with

$partstring

OPTIONAL Part of the date to compare, if null the timestamp is used

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
boolean
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicisLater(string | integer | array | \Zend_Date $date, string $part = null, string | \Zend_Locale $locale = null) : boolean

Returns if the given date or datepart is later For example: 15.May.2000 <-> 13.June.1999 will return true for month but false for day, year and date Returns if the given date is later

Parameters
NameTypeDescription
$datestring | integer | array | \Zend_Date

Date or datepart to compare with

$partstring

OPTIONAL Part of the date to compare, if null the timestamp is used

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
boolean
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicisLeapYear() : boolean

Returns true, if the year is a leap year.

Returns
TypeDescription
boolean
methodpublicisToday() : boolean

Returns if the set date is todays date

Returns
TypeDescription
boolean
methodpublicisTomorrow() : boolean

Returns if the set date is tomorrows date

Returns
TypeDescription
boolean
methodpublicisYesterday() : boolean

Returns if the set date is yesterdays date

Returns
TypeDescription
boolean
methodpublicnow(string | \Zend_Locale $locale = null) : \Zend_Date
static

Returns the actual date as new date object

Parameters
NameTypeDescription
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_Date
methodpublicset(string | integer | array | \Zend_Date $date, string $part = null, string | \Zend_Locale $locale = null) : \Zend_Date

Sets the given date as new date or a given datepart as new datepart returning the new datepart This could be for example a localized dayname, the date without time, the month or only the seconds. There are about 50 different supported date parts.

For a complete list of supported datepart values look into the docu
Parameters
NameTypeDescription
$datestring | integer | array | \Zend_Date

Date or datepart to set

$partstring

OPTIONAL Part of the date to set, if null the timestamp is set

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetArpa(string | integer | \Zend_Date $date, string | \Zend_Locale $locale = null) : \Zend_Date

Sets a RFC 822 date as new date for the date object.

Only RFC 822 compilant date strings are accepted. For example: Sat, 14 Feb 09 00:31:30 +0100 Returned is the new date object
Parameters
NameTypeDescription
$datestring | integer | \Zend_Date

RFC 822 to set

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetDate(string | integer | array | \Zend_Date $date, string $format = null, string | \Zend_Locale $locale = null) : \Zend_Date

Sets a new date for the date object. Format defines how to parse the date string.

Also a complete date with time can be given, but only the date is used for setting. For example: MMMM.yy HH:mm-> May.07 22:11 => 01.May.07 00:00 Returned is the new date object and the existing time is left as it was before
Parameters
NameTypeDescription
$datestring | integer | array | \Zend_Date

Date to set

$formatstring

OPTIONAL Date format for parsing

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetDay( $day, string | \Zend_Locale $locale = null) : \Zend_Date

Sets a new day The day can be a number or a string. Setting days lower then 0 or greater than the number of this months days will result in adding or subtracting the relevant month.

If a localized dayname is given it will be parsed with the default locale or the optional set locale. Returned is the new date object Example: setDay('Montag', 'de_AT'); will set the monday of this week as day.
Parameters
NameTypeDescription
$day
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetDayOfYear(string | integer | array | \Zend_Date $day, string | \Zend_Locale $locale = null) : \Zend_Date

Sets a new day of year The day of year is always a number.

Returned is the new date object Example: 04.May.2004 -> setDayOfYear(10) -> 10.Jan.2004
Parameters
NameTypeDescription
$daystring | integer | array | \Zend_Date

Day of Year to set

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetFractionalPrecision(integer $precision) : \Zend_Date

Sets a new precision for fractional seconds

Parameters
NameTypeDescription
$precisioninteger

Precision for the fractional datepart 3 = milliseconds

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetHour(string | integer | array | \Zend_Date $hour, string | \Zend_Locale $locale = null) : \Zend_Date

Sets a new hour The hour is always a number.

Returned is the new date object Example: 04.May.1993 13:07:25 -> setHour(7); -> 04.May.1993 07:07:25
Parameters
NameTypeDescription
$hourstring | integer | array | \Zend_Date

Hour to set

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetIso(string | integer | \Zend_Date $date, string | \Zend_Locale $locale = null) : \Zend_Date

Sets a new date for the date object. Not given parts are set to default.

Only supported ISO 8601 formats are accepted. For example: 050901 -> 01.Sept.2005 00:00:00, 20050201T10:00:30 -> 01.Feb.2005 10h00m30s Returned is the new date object
Parameters
NameTypeDescription
$datestring | integer | \Zend_Date

ISO Date to set

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetLocale(string | \Zend_Locale $locale = null) : \Zend_Date

Sets a new standard locale for the date object.

This locale will be used for all functions Returned is the really set locale. Example: 'de_XX' will be set to 'de' because 'de_XX' does not exist 'xx_YY' will be set to 'root' because 'xx' does not exist
Parameters
NameTypeDescription
$localestring | \Zend_Locale

(Optional) Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluent interface
Throws
ExceptionDescription
\Zend_Date_ExceptionWhen the given locale does not exist
methodpublicsetMilliSecond(integer | \Zend_Date $milli = null, integer $precision = null) : \Zend_Date

Sets new milliseconds for the date object Example: setMilliSecond(550, 2) -> equals +5 Sec +50 MilliSec

Parameters
NameTypeDescription
$milliinteger | \Zend_Date

(Optional) Millisecond to set, when null the actual millisecond is set

$precisioninteger

(Optional) Fraction precision of the given milliseconds

Returns
TypeDescription
\Zend_DateProvides fluid interface
methodpublicsetMinute(string | integer | array | \Zend_Date $minute, string | \Zend_Locale $locale = null) : \Zend_Date

Sets a new minute The minute is always a number.

Returned is the new date object Example: 04.May.1993 13:07:25 -> setMinute(29); -> 04.May.1993 13:29:25
Parameters
NameTypeDescription
$minutestring | integer | array | \Zend_Date

Minute to set

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetMonth(string | integer | array | \Zend_Date $month, string | \Zend_Locale $locale = null) : \Zend_Date

Sets a new month The month can be a number or a string. Setting months lower then 0 and greater then 12 will result in adding or subtracting the relevant year. (12 months equal one year) If a localized monthname is given it will be parsed with the default locale or the optional set locale.

Returned is the new date object
Parameters
NameTypeDescription
$monthstring | integer | array | \Zend_Date

Month to set

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetOptions(array $options = array()) : \Options
static

Sets class wide options, if no option was given, the actual set options will be returned

Parameters
NameTypeDescription
$optionsarray

Options to set

Returns
TypeDescription
\Optionsarray if no option was given
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetSecond(string | integer | array | \Zend_Date $second, string | \Zend_Locale $locale = null) : \Zend_Date

Sets new seconds to the existing date object.

The second is always a number. Returned is the new date object Example: 04.May.1993 13:07:25 -> setSecond(100); -> 04.May.1993 13:08:40
Parameters
NameTypeDescription
$secondstring | integer | array | \Zend_Date

Second to set

$localestring | \Zend_Locale

(Optional) Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetTime(string | integer | array | \Zend_Date $time, string $format = null, string | \Zend_Locale $locale = null) : \Zend_Date

Sets a new time for the date object. Format defines how to parse the time string.

Also a complete date can be given, but only the time is used for setting. For example: dd.MMMM.yyTHH:mm' and 'ss sec'-> 10.May.07T25:11 and 44 sec => 1h11min44sec + 1 day Returned is the new date object and the existing date is left as it was before
Parameters
NameTypeDescription
$timestring | integer | array | \Zend_Date

Time to set

$formatstring

OPTIONAL Timeformat for parsing input

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetTimestamp(integer | string | array | \Zend_Date $timestamp) : \Zend_Date

Sets a new timestamp

Parameters
NameTypeDescription
$timestampinteger | string | array | \Zend_Date

Timestamp to set

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetWeek(string | integer | array | \Zend_Date $week, string | \Zend_Locale $locale = null) : \Zend_Date

Sets a new week. The week is always a number. The day of week is not changed.

Returned is the new date object Example: 09.Jan.2007 13:07:25 -> setWeek(1); -> 02.Jan.2007 13:07:25
Parameters
NameTypeDescription
$weekstring | integer | array | \Zend_Date

Week to set

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetWeekday( $weekday, string | \Zend_Locale $locale = null) : \Zend_Date

Sets a new weekday The weekday can be a number or a string. If a localized weekday name is given, then it will be parsed as a date in $locale (defaults to the same locale as $this).

Returned is the new date object. Example: setWeekday(3); will set the wednesday of this week as day.
Parameters
NameTypeDescription
$weekday
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsetYear( $year, string | \Zend_Locale $locale = null) : \Zend_Date

Sets a new year If the year is between 0 and 69, 2000 will be set (2000-2069) If the year if between 70 and 99, 1999 will be set (1970-1999) 3 or 4 digit years are set as expected. If you need to set year 0-99 use set() instead.

Returned is the new date object
Parameters
NameTypeDescription
$year
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsub(string | integer | array | \Zend_Date $date, string $part = self::TIMESTAMP, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts a date from another date.

This could be for example a RFC2822 date, the time, the year or only the timestamp. There are about 50 different supported date parts. For a complete list of supported datepart values look into the docu Be aware: Adding -2 Months is not equal to Subtracting 2 Months !!!
Parameters
NameTypeDescription
$datestring | integer | array | \Zend_Date

Date or datepart to subtract

$partstring

OPTIONAL Part of the date to sub, if null the timestamp is subtracted

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubArpa(string | integer | \Zend_Date $date, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts a RFC 822 date from the date object.

ARPA messages are used in emails or HTTP Headers. Only RFC 822 compilant date strings are accepted. For example: Sat, 14 Feb 09 00:31:30 +0100 Returned is the new date object
Parameters
NameTypeDescription
$datestring | integer | \Zend_Date

RFC 822 Date to sub

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubDate(string | integer | array | \Zend_Date $date, string $format = null, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts a date from the existing date object. Format defines how to parse the date string.

If only parts are given the other parts are set to 0. If no format is given, the standardformat of this locale is used. For example: MM.dd.YYYY -> 10 -> -10 months Be aware: Subtracting 2 months is not equal to Adding -2 months !!!
Parameters
NameTypeDescription
$datestring | integer | array | \Zend_Date

Date to sub

$formatstring

OPTIONAL Date format for parsing input

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubDay( $day, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts days from the existing date object.

The day can be a number or a string. Subtracting days lower then 0 or greater than the number of this months days will result in adding or subtracting the relevant month. If a localized dayname is given it will be parsed with the default locale or the optional set locale.
Parameters
NameTypeDescription
$day
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubDayOfYear(string | integer | array | \Zend_Date $day, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts a day of year from the existing date object.

The day of year is always a number. Returned is the new date object Example: subDayOfYear(10); will subtract 10 days from the existing date object.
Parameters
NameTypeDescription
$daystring | integer | array | \Zend_Date

Day of Year to sub

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubHour(string | integer | array | \Zend_Date $hour, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts hours from the existing date object.

The hour is always a number. Returned is the new date object Example: 04.May.1993 13:07:25 -> subHour(6); -> 05.May.1993 07:07:25
Parameters
NameTypeDescription
$hourstring | integer | array | \Zend_Date

Hour to sub

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubIso(string | integer | \Zend_Date $date, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts a ISO date from the date object. Not given parts are set to default.

Only supported ISO 8601 formats are accepted. For example: 050901 -> - 01.Sept.2005 00:00:00, 10:00:00 -> -10h Returned is the new date object
Parameters
NameTypeDescription
$datestring | integer | \Zend_Date

ISO Date to sub

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubMilliSecond(integer | \Zend_Date $milli = null, integer $precision = null) : \Zend_Date

Subtracts a millisecond

Parameters
NameTypeDescription
$milliinteger | \Zend_Date

(Optional) Millisecond to sub, when null the actual millisecond is subtracted

$precisioninteger

(Optional) Fractional precision for the given milliseconds

Returns
TypeDescription
\Zend_DateProvides fluid interface
methodpublicsubMinute(string | integer | array | \Zend_Date $minute, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts minutes from the existing date object.

The minute is always a number. Returned is the new date object Example: 04.May.1993 13:07:25 -> subMinute(9); -> 04.May.1993 12:58:25
Parameters
NameTypeDescription
$minutestring | integer | array | \Zend_Date

Minute to sub

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubMonth(string | integer | array | \Zend_Date $month, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts months from the existing date object.

The month can be a number or a string. Subtracting months lower then 0 and greater then 12 will result in adding or subtracting the relevant year. (12 months equal one year) If a localized monthname is given it will be parsed with the default locale or the optional set locale. Returned is the new date object
Parameters
NameTypeDescription
$monthstring | integer | array | \Zend_Date

Month to sub

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubSecond(string | integer | array | \Zend_Date $second, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts seconds from the existing date object.

The second is always a number. Returned is the new date object Example: 04.May.1993 13:07:25 -> subSecond(10); -> 04.May.1993 13:07:15
Parameters
NameTypeDescription
$secondstring | integer | array | \Zend_Date

Second to sub

$localestring | \Zend_Locale

(Optional) Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubTime(string | integer | array | \Zend_Date $time, string $format = null, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts a time from the existing date. Format defines how to parse the time string.

If only parts are given the other parts are set to 0. If no format is given, the standardformat of this locale is used. For example: HH:mm:ss -> 10 -> -10 hours
Parameters
NameTypeDescription
$timestring | integer | array | \Zend_Date

Time to sub

$formatstring

OPTIONAL Timeformat for parsing input

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid inteface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubTimestamp(integer | string | array | \Zend_Date $timestamp) : \Zend_Date

Subtracts a timestamp

Parameters
NameTypeDescription
$timestampinteger | string | array | \Zend_Date

Timestamp to sub

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubWeek(string | integer | array | \Zend_Date $week, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts a week. The week is always a number. The day of week is not changed.

Returned is the new date object Example: 09.Jan.2007 13:07:25 -> subWeek(1); -> 02.Jan.2007 13:07:25
Parameters
NameTypeDescription
$weekstring | integer | array | \Zend_Date

Week to sub

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubWeekday( $weekday, string | \Zend_Locale $locale = null) : \Zend_Date

Subtracts weekdays from the existing date object.

The weekday can be a number or a string. If a localized dayname is given it will be parsed with the default locale or the optional set locale. Returned is the new date object Example: subWeekday(3); will subtract the difference of days from the begining of the month until wednesday.
Parameters
NameTypeDescription
$weekday
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublicsubYear( $year, string | \Zend_Locale $locale = null) : \Zend_Date

Subs the year from the existing date object If the year is between 0 and 69, 2000 will be subtracted (2000-2069) If the year if between 70 and 99, 1999 will be subtracted (1970-1999) 3 or 4 digit years are subtracted as expected. If you need to subtract years from 0-99 use sub() instead.

Returned is the new date object
Parameters
NameTypeDescription
$year
$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
\Zend_DateProvides fluid interface
Throws
ExceptionDescription
\Zend_Date_Exception
methodpublictoArray() : array

Returns an array representation of the object

Returns
TypeDescription
array
methodpublictoString(string $format = null, string $type = null, string | \Zend_Locale $locale = null) : string

Returns a string representation of the object Supported format tokens are: G - era, y - year, Y - ISO year, M - month, w - week of year, D - day of year, d - day of month E - day of week, e - number of weekday (1-7), h - hour 1-12, H - hour 0-23, m - minute, s - second A - milliseconds of day, z - timezone, Z - timezone offset, S - fractional second, a - period of day

Additionally format tokens but non ISO conform are: SS - day suffix, eee - php number of weekday(0-6), ddd - number of days per month l - Leap year, B - swatch internet time, I - daylight saving time, X - timezone offset in seconds r - RFC2822 format, U - unix timestamp Not supported ISO tokens are u - extended year, Q - quarter, q - quarter, L - stand alone month, W - week of month F - day of week of month, g - modified julian, c - stand alone weekday, k - hour 0-11, K - hour 1-24 v - wall zone
Parameters
NameTypeDescription
$formatstring

OPTIONAL Rule for formatting output. If null the default date format is used

$typestring

OPTIONAL Type for the format string which overrides the standard setting

$localestring | \Zend_Locale

OPTIONAL Locale for parsing input

Returns
TypeDescription
string
methodpublictoValue(string | integer | \Zend_Date $part = null) : integer | false

Returns a integer representation of the object But returns false when the given part is no value f.e. Month-Name

Parameters
NameTypeDescription
$partstring | integer | \Zend_Date

OPTIONAL Defines the date or datepart to return as integer

Returns
TypeDescription
integer | false
Documentation was generated by phpDocumentor 2.2.0 .