Date
[ class tree: Date ] [ index: Date ] [ all elements ]

Class: Date

Source Location: /Date-1.5.0a4/Date.php

Class Overview


Generic date handling class for PEAR


Author(s):

Version:

  • Release: 1.5.0a1

Copyright:

  • 1997-2007 Baba Buehler, Pierre-Alain Joye, Firman Wandayandi, C.A. Woodcock

Methods


Inherited Variables

Inherited Methods


Class Details

[line 273]
Generic date handling class for PEAR

Supports time zones with the Date_TimeZone class. Supports several operations from Date_Calc on Date objects.

Note to developers: the class stores the local time and date in the local standard time. That is, it does not store the time as the local Summer time when and if the time zone is in Summer time. It is much easier to store local standard time and remember to offset it when the user requests it.



[ Top ]


Method Detail

Date (Constructor)   [line 476]

void Date( [mixed $date = null], [bool $pb_countleapseconds = DATE_COUNT_LEAP_SECONDS])

Constructor

Creates a new Date Object initialized to the current date/time in the system-default timezone by default. A date optionally passed in may be in the ISO 8601, TIMESTAMP or UNIXTIME format, or another Date object. If no date is passed, the current date/time is used.

If a date is passed and an exception is returned by Date::setDate() there is nothing that this function can do, so for this reason, it is advisable to pass no parameter and to make a separate call to Date::setDate(). A date/time should only be passed if known to be a valid ISO 8601 string or a valid Unix timestamp.


Parameters:

mixed   $date     optional ISO 8601 date/time to initialize; or, a Unix time stamp
bool   $pb_countleapseconds     whether to count leap seconds (defaults to DATE_COUNT_LEAP_SECONDS)

[ Top ]

addDays   [line 4040]

void addDays( int $pn_days)

Converts the date to the specified no of days from the given date

To subtract days use a negative value for the '$pn_days' parameter

  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_days     days to add

[ Top ]

addHours   [line 4072]

void addHours( int $pn_hours)

Converts the date to the specified no of hours from the given date

To subtract hours use a negative value for the '$pn_hours' parameter

  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_hours     hours to add

[ Top ]

addMinutes   [line 4111]

void addMinutes( int $pn_minutes)

Converts the date to the specified no of minutes from the given date

To subtract minutes use a negative value for the '$pn_minutes' parameter

  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_minutes     minutes to add

[ Top ]

addMonths   [line 4008]

void addMonths( int $pn_months)

Converts the date to the specified no of months from the given date

To subtract months use a negative value for the '$pn_months' parameter

  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_months     months to add

[ Top ]

addSeconds   [line 4151]

void addSeconds( mixed $sec, [bool $pb_countleap = null])

Adds a given number of seconds to the date
  • Access: public

Parameters:

mixed   $sec     the no of seconds to add as integer or float
bool   $pb_countleap     whether to count leap seconds (defaults to value of count-leap-second object property)

[ Top ]

addSpan   [line 4343]

void addSpan( object $span)

Adds a time span to the date

A time span is defined as a unsigned no of days, hours, minutes and seconds, where the no of minutes and seconds must be less than 60, and the no of hours must be less than 24.

A span is added (and subtracted) according to the following logic:

Hours, minutes and seconds are added such that if they fall over a leap second, the leap second is ignored, and not counted. For example, if a leap second occurred at 23.59.60, the following calculations:

  • 23.59.59 + one second
  • 23.59.00 + one minute
  • 23.00.00 + one hour
would all produce 00.00.00 the next day.

A day is treated as equivalent to 24 hours, so if the clocks went backwards at 01.00, and one day was added to the time 00.30, the result would be 23.30 the same day.

This is the implementation which is thought to yield the behaviour that the user is most likely to expect, or in another way of looking at it, it is the implementation that produces the least unexpected behaviour. It basically works in hours, that is, a day is treated as exactly equivalent to 24 hours, and minutes and seconds are treated as equivalent to 1/60th and 1/3600th of an hour. It should be obvious that working in days is impractical; working in seconds is problematic when it comes to adding days that fall over leap seconds, where it would appear to most users that the function adds only 23 hours, 59 minutes and 59 seconds. It is also problematic to work in any kind of mixture of days, hours, minutes, and seconds, because then the addition of a span would sometimes depend on which order you add the constituent parts, which undermines the concept of a span altogether.

If you want alternative functionality, you must use a mixture of the following functions instead:


Parameters:

object   $span     the time span to add

[ Top ]

addYears   [line 3975]

void addYears( int $pn_years)

Converts the date to the specified no of years from the given date

To subtract years use a negative value for the '$pn_years' parameter

  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_years     years to add

[ Top ]

after   [line 4661]

boolean after( object $when)

Test if this date/time is after a certain date/time
  • Return: true if this date is after $when
  • Access: public

Parameters:

object   $when     the Date object to test against

[ Top ]

before   [line 4636]

boolean before( object $when)

Test if this date/time is before a certain date/time
  • Return: true if this date is before $when
  • Access: public

Parameters:

object   $when     the Date object to test against

[ Top ]

compare   [line 4573]

int compare( object $od1, object $od2)

Compares two dates

Suitable for use in sorting functions

  • Return: 0 if the dates are equal, -1 if '$od1' is before '$od2', 1 if '$od1' is after '$od2'
  • Access: public

Parameters:

object   $od1     the first Date object to compare
object   $od2     the second Date object to compare

[ Top ]

convertTZ   [line 3827]

void convertTZ( object $tz)

Converts this date to a new time zone

Previously this might not have worked correctly if your system did not allow putenv() or if localtime() did not work in your environment, but this implementation is no longer used.


Parameters:

object   $tz     Date_TimeZone object to convert to

[ Top ]

convertTZByID   [line 3905]

void convertTZByID( string $ps_id)

Converts this date to a new time zone, given a valid time zone ID

Previously this might not have worked correctly if your system did not allow putenv() or if localtime() did not work in your environment, but this implementation is no longer used.


Parameters:

string   $ps_id     a valid time zone id, e.g. 'Europe/London'

[ Top ]

copy   [line 510]

void copy( object $date)

Copy values from another Date object

Makes this Date a copy of another Date object. This is a PHP4-compatible implementation of Date::__clone() in PHP5.

  • Access: public

Parameters:

object   $date     Date object to copy

[ Top ]

dateDiff   [line 4483]

mixed dateDiff( object $po_date, [bool $pb_ignoretime = false])

Subtract supplied date and return answer in days

If the second parameter '$pb_ignoretime' is specified as false, the time parts of the two dates will be ignored, and the integral no of days between the day/month/year parts of the two dates will be returned. If either of the two dates have an invalid time, the integral no of days will also be returned, else the returned value will be the no of days as a float, with each hour being treated as 1/24th of a day and so on.

For example,

  • 21/11/2007 13.00 minus 21/11/2007 01.00
returns 0.5

Note that if the passed date is in the past, a positive value will be returned, and if it is in the future, a negative value will be returned.

  • Return: days between two dates as int or float
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

object   $po_date     date to subtract
bool   $pb_ignoretime     whether to ignore the time values of the two dates in subtraction (defaults to false)

[ Top ]

equals   [line 4686]

boolean equals( object $when)

Test if this date/time is exactly equal to a certain date/time
  • Return: true if this date is exactly equal to $when
  • Access: public

Parameters:

object   $when     the Date object to test against

[ Top ]

format   [line 1310]

string format( )

Formats the date according to the specified formatting code string

This function is an alias for the method specified by the constant DATE_FORMAT_METHOD (which defaults to 'formatLikeStrftime' for backwards-compatibility).


[ Top ]

formatLikeDate   [line 3292]

string formatLikeDate( string $ps_format)

Formats the date according to the specified formatting code string, based on date()

All date() formatting options are supported except 'B'. This function also responds to the DATE_* constants, such as DATE_COOKIE, which are specified at:

http://www.php.net/manual/en/datetime.constants.php

Formatting options:

(Day)

  • d - Day of the month, 2 digits with leading zeros (01 to 31)
  • D - A textual representation of a day, three letters ('Mon' to 'Sun')
  • j - Day of the month without leading zeros (1 to 31)
  • l - [lowercase 'L'] A full textual representation of the day of the week ('Sunday' to 'Saturday')
  • N - ISO-8601 numeric representation of the day of the week (1 (for Monday) to 7 (for Sunday)) (see 'W')
  • S - English ordinal suffix for the day of the month, 2 characters ('st', 'nd', 'rd' or 'th')
  • w - Numeric representation of the day of the week (0 (for Sunday) to 6 (for Saturday))
  • z - The day of the year, starting from 0 (0 to 365)
(Week)

  • W - ISO-8601 week number of year, weeks starting on Monday (00 to 53)
(Month)

  • F - A full textual representation of a month ('January' to 'December')
  • m - Numeric representation of a month, with leading zeros (01 to 12)
  • M - A short textual representation of a month, three letters ('Jan' to 'Dec')
  • n - Numeric representation of a month, without leading zeros (1 to 12)
  • t - Number of days in the given month (28 to 31)
(Year)

  • L - Whether it is a leap year (1 if it is a leap year, 0 otherwise)
  • o - ISO-8601 year number (see 'W'). This has the same value as 'Y', except that if the ISO week number ('W') belongs to the previous or next year, that year is used instead.
  • Y - A full numeric representation of a year, 4 digits (0000 to 9999)
  • y - A two digit representation of a year (00 to 99)
(Time)

  • a - Lowercase Ante meridiem and Post meridiem ('am' or 'pm')
  • A - Uppercase Ante meridiem and Post meridiem ('AM' or 'PM')
  • g - 12-hour format of an hour without leading zeros (1 to 12)
  • G - 24-hour format of an hour without leading zeros (0 to 23)
  • h - 12-hour format of an hour with leading zeros (01 to 12)
  • H - 24-hour format of an hour with leading zeros (00 to 23)
  • i - Minutes with leading zeros (00 to 59)
  • s - Seconds, with leading zeros (00 to 59)
  • u - Milliseconds, e.g. '54321'
(Time Zone)

  • e - Timezone identifier, e.g. Europe/London
  • I - Whether or not the date is in Summer time (1 if Summer time, 0 otherwise)
  • O - Difference to Greenwich time (GMT) in hours, e.g. '+0200'
  • P - Difference to Greenwich time (GMT) with colon between hours and minutes, e.g. '+02:00'
  • T - Timezone abbreviation, e.g. 'GMT', 'EST'
  • Z - Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. (-43200 to 50400)
(Full Date/Time)

  • c - ISO 8601 date, e.g. '2004-02-12T15:19:21+00:00'
  • r - RFC 2822 formatted date, e.g. 'Thu, 21 Dec 2000 16:01:07 +0200'
  • U - Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)


Parameters:

string   $ps_format     the format string for returned date/time

[ Top ]

formatLikeSQL   [line 2166]

string formatLikeSQL( string $ps_format, [string $ps_locale = "en_GB"])

Formats the date according to the specified formatting code string, based on SQL date-formatting codes

Most codes reproduce the no of digits equal to the length of the code, for example, 'YYY' will return the last 3 digits of the year, and so the year 2007 will produce '007', and the year 89 will produce '089', unless the no-padding code is used as in 'NPYYY', which will return '89'.

For negative values, the sign will be discarded, unless the 'S' code is used in combination, but note that for positive values the value will be padded with a leading space unless it is suppressed with the no-padding modifier, for example for 2007:

  • YYYY - returns '2007'
  • SYYYY - returns ' 2007'
  • NPSYYYY - returns '2007'
The no-padding modifier 'NP' can be used with numeric codes to suppress leading (or trailing in the case of code 'F') noughts, and with character-returning codes such as 'DAY' to suppress trailing spaces, which will otherwise be padded to the maximum possible length of the return-value of the code; for example, for Monday:

  • Day - returns 'Monday ' because the maximum length of this code is 'Wednesday';
  • NPDay - returns 'Monday'
N.B. this code affects the code immediately following only, and without this code the default is always to apply padding.

Most character-returning codes, such as 'MONTH', will set the capitalization according to the code, so for example:

  • MONTH - returns upper-case spelling, e.g. 'JANUARY'
  • Month - returns spelling with first character of each word capitalized, e.g. 'January'
  • month - returns lower-case spelling, e.g. 'january'
Where it makes sense, numeric codes can be combined with a following 'SP' code which spells out the number, or with a 'TH' code, which renders the code as an ordinal ('TH' only works in English), for example, for 31st December:

  • DD - returns '31'
  • DDTH - returns '31ST'
  • DDth - returns '31st'
  • DDSP - returns 'THIRTY-ONE'
  • DDSp - returns 'Thirty-one'
  • DDsp - returns 'thirty-one'
  • DDSPTH - returns 'THIRTY-FIRST'
  • DDSpth - returns 'Thirty-first'
  • DDspth - returns 'thirty-first'

All formatting options:

  • - (All punctuation and white-space is reproduced unchanged)
  • /
  • ,
  • .
  • ;
  • :
  • "text" - Quoted text is reproduced unchanged (escape using '\')
  • AD - AD indicator with or without full stops
  • A.D.
  • AM - Meridian indicator with or without full stops
  • A.M.
  • BC - BC indicator with or without full stops
  • B.C.
  • BCE - BCE indicator with or without full stops
  • B.C.E.
  • CC - Century, i.e. the year divided by 100, discarding the remainder; 'S' prefixes negative years with a minus sign
  • SCC
  • CE - CE indicator with or without full stops
  • C.E.
  • D - Day of week (0-6), where 0 represents Sunday
  • DAY - Name of day, padded with blanks to display width of the widest name of day in the locale of the machine
  • DD - Day of month (1-31)
  • DDD - Day of year (1-366)
  • DY - Abbreviated name of day
  • FFF - Fractional seconds; no radix character is printed. The no of 'F's determines the no of digits of the part-second to return; e.g. 'HH:MI:SS.FF'
  • F[integer] - The integer after 'F' specifies the number of digits of the part-second to return. This is an alternative to using several 'F's in sequence, and 'F3' is thus equivalent to using 'FFF'.
  • HH - Hour of day (0-23)
  • HH12 - Hour of day (1-12)
  • HH24 - Hour of day (0-23)
  • ID - Day of week (1-7) based on the ISO 8601 standard (see 'IW')
  • IW - Week of year (1-52 or 1-53) based on the ISO 8601 standard
  • IYYY - 4-digit year based on the ISO 8601 standard (see 'IW'); 'S' prefixes negative years with a minus sign
  • SIYYY
  • IYY - Last 3, 2, or 1 digit(s) of ISO year
  • IY
  • I
  • J - Julian day - the number of days since Monday, 24th November, 4714 B.C. (proleptic Gregorian calendar)
  • MI - Minute (0-59)
  • MM - Month (01-12; January = 01)
  • MON - Abbreviated name of month
  • MONTH - Name of month, padded with blanks to display width of the widest name of month in the date language used for
  • PM - Meridian indicator with or without full stops
  • P.M.
  • Q - Quarter of year (1, 2, 3, 4; January - March = 1)
  • RM - Roman numeral month (I-XII; January = I); N.B. padded with leading spaces.
  • SS - Second (0-59)
  • SSSSS - Seconds past midnight (0-86399)
  • TZC - Abbreviated form of time zone name, e.g. 'GMT', or the abbreviation for Summer time if the date falls in Summer time, e.g. 'BST'. N.B. this is not a unique identifier - for this purpose use the time zone region (code 'TZR').
  • TZH - Time zone hour; 'S' prefixes the hour with the correct sign, (+/-), which otherwise is not displayed. Note that the leading nought can be suppressed with the no-padding code 'NP'). Also note that if you combine with the 'SP' code, the sign will not be spelled out. (I.e. 'STZHSp' will produce '+One', for example, and not 'Plus One'. 'TZH:TZM' will produce, for example, '+05:30'. (Also see 'TZM' format code)
  • STZH
  • TZI - Whether or not the date is in Summer time (daylight saving time). Returns '1' if Summer time, else '0'.
  • TZM - Time zone minute, without any +/- sign. (Also see 'TZH' format element)
  • TZN - Long form of time zone name, e.g. 'Greenwich Mean Time', or the name of the Summer time if the date falls in Summer time, e.g. 'British Summer Time'. N.B. this is not a unique identifier - for this purpose use the time zone region (code 'TZR').
  • TZO - Time zone offset in ISO 8601 form - that is, 'Z' if UTC, else [+/-][hh]:[mm] (which would be equivalent to 'STZH:TZM'). Note that this result is right padded. with spaces by default, (i.e. if 'Z').
  • TZS - Time zone offset in seconds; 'S' prefixes negative sign with minus sign '-' if negative, and no sign if positive (i.e. -43200 to 50400).
  • STZS
  • TZR - Time zone region, that is, the name or ID of the time zone e.g. 'Europe/London'. This value is unique for each time zone.
  • U - Seconds since the Unix Epoch - January 1 1970 00:00:00 GMT
  • W - 'Absolute' week of month (1-5), counting week 1 as 1st-7th of the year, regardless of the day
  • W1 - Week of year (1-54), counting week 1 as the week that contains 1st January
  • W4 - Week of year (1-53), counting week 1 as the week that contains 4th January (i.e. first week with at least 4 days)
  • W7 - Week of year (1-53), counting week 1 as the week that contains 7th January (i.e. first full week)
  • WW - 'Absolute' week of year (1-53), counting week 1 as 1st-7th of the year, regardless of the day
  • YEAR - Year, spelled out; 'S' prefixes negative years with 'MINUS'; N.B. 'YEAR' differs from 'YYYYSP' in that the first will render 1923, for example, as 'NINETEEN TWENTY-THREE, and the second as 'ONE THOUSAND NINE HUNDRED TWENTY-THREE'
  • SYEAR
  • YYYY - 4-digit year; 'S' prefixes negative years with a minus sign
  • SYYYY
  • YYY - Last 3, 2, or 1 digit(s) of year
  • YY
  • Y
  • Y,YYY - Year with thousands-separator in this position; five possible separators
  • Y.YYY
  • Y·YYY - N.B. space-dot (mid-dot, interpunct) is valid only in ISO 8859-1 (so take care when using UTF-8 in particular)
  • Y'YYY
  • Y YYY
In addition the following codes can be used in combination with other codes; Codes that modify the next code in the format string:

  • NP - 'No Padding' - Returns a value with no trailing blanks and no leading or trailing noughts; N.B. that the default is to include this padding in the return string. N.B. affects the code immediately following only.
Codes that modify the previous code in the format string (can only be used with integral codes such as 'MM'):

  • TH - Ordinal number
  • SP - Spelled cardinal number
  • SPTH - Spelled ordinal number (combination of 'SP' and 'TH' in any order)
  • THSP
Code 'SP' can have the following three variations (which can also be used in combination with 'TH'):

  • SP - returns upper-case spelling, e.g. 'FOUR HUNDRED'
  • Sp - returns spelling with first character of each word capitalized, e.g. 'Four Hundred'
  • sp - returns lower-case spelling, e.g. 'four hundred'
Code 'TH' can have the following two variations (although in combination with code 'SP', the case specification of 'SP' takes precedence):

  • TH - returns upper-case ordinal suffix, e.g. 400TH
  • th - returns lower-case ordinal suffix, e.g. 400th


Parameters:

string   $ps_format     format string for returned date/time
string   $ps_locale     language name abbreviation used for formatting numbers as spelled-out words

[ Top ]

formatLikeStrftime   [line 1421]

string formatLikeStrftime( string $format)

Formats the date according to the specified formatting code string, based on strftime()

Formats the date in the given format, much like strftime(). Most strftime() options are supported.

Formatting options:

  • %a - abbreviated weekday name (Sun, Mon, Tue)
  • %A - full weekday name (Sunday, Monday, Tuesday)
  • %b - abbreviated month name (Jan, Feb, Mar)
  • %B - full month name (January, February, March)
  • %C - century number (the year divided by 100 and truncated to an integer, range 00 to 99)
  • %d - day of month (range 00 to 31)
  • %D - equivalent to '%m/%d/%y'
  • %e - day of month without leading noughts (range 0 to 31)
  • %E - Julian day - no of days since Monday, 24th November, 4714 B.C. (in the proleptic Gregorian calendar)
  • %g - like '%G', but without the century
  • %G - the 4-digit year corresponding to the ISO week number (see '%V'). This has the same format and value as '%Y', except that if the ISO week number belongs to the previous or next year, that year is used instead.
  • %h - hour as decimal number without leading noughts (0 to 23)
  • %H - hour as decimal number (00 to 23)
  • %i - hour as decimal number on 12-hour clock without leading noughts (1 to 12)
  • %I - hour as decimal number on 12-hour clock (01 to 12)
  • %j - day of year (range 001 to 366)
  • %m - month as decimal number (range 01 to 12)
  • %M - minute as a decimal number (00 to 59)
  • %n - newline character ("\n")
  • %o - raw timezone offset expressed as '+/-HH:MM'
  • %O - dst-corrected timezone offset expressed as '+/-HH:MM'
  • %p - either 'am' or 'pm' depending on the time
  • %P - either 'AM' or 'PM' depending on the time
  • %r - time in am/pm notation; equivalent to '%I:%M:%S %p'
  • %R - time in 24-hour notation; equivalent to '%H:%M'
  • %s - seconds including the micro-time (the decimal representation less than one second to six decimal places
  • %S - seconds as a decimal number (00 to 59)
  • %t - tab character ("\t")
  • %T - current time; equivalent to '%H:%M:%S'
  • %u - day of week as decimal (1 to 7; where 1 = Monday)
  • %U - week number of the current year as a decimal number, starting with the first Sunday as the first day of the first week (i.e. the first full week of the year, and the week that contains 7th January) (00 to 53)
  • %V - the ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. (Use '%G' or '%g' for the year component that corresponds to the week number for the specified timestamp.)
  • %w - day of week as decimal (0 to 6; where 0 = Sunday)
  • %W - week number of the current year as a decimal number, starting with the first Monday as the first day of the first week (i.e. the first full week of the year, and the week that contains 7th January) (00 to 53)
  • %y - year as decimal (range 00 to 99)
  • %Y - year as decimal including century (range 0000 to 9999)
  • %Z - Abbreviated form of time zone name, e.g. 'GMT', or the abbreviation for Summer time if the date falls in Summer time, e.g. 'BST'.
  • %% - literal '%'

The following codes render a different output to that of strftime():

  • %e - in 'strftime()' a single digit is preceded by a space
  • %h - in 'strftime()' is equivalent to '%b'
  • %U - '%U' and '%W' are different in 'strftime()' in that if week 1 does not start on 1st January, '00' is returned, whereas this function returns '53', that is, the week is counted as the last of the previous year.
  • %W


Parameters:

string   $format     the format string for returned date/time

[ Top ]

getDate   [line 1252]

string getDate( [int $format = DATE_FORMAT_ISO])

Gets a string (or other) representation of this date

Returns a date in the format specified by the DATE_FORMAT_* constants, which should be one of the following:

  • Return: the date in the requested format (defaults to DATE_FORMAT_ISO)
  • Access: public

Parameters:

int   $format     format constant (DATE_FORMAT_*) of the output date

[ Top ]

getDay   [line 5042]

int getDay( )

Returns the day field of the date object
  • Return: the day
  • Access: public

[ Top ]

getDayName   [line 4881]

string getDayName( [bool $abbr = false], [int $length = 3])

Gets the full name or abbreviated name of this weekday
  • Return: name of this day
  • Access: public

Parameters:

bool   $abbr     abbreviate the name
int   $length     length of abbreviation

[ Top ]

getDayOfWeek   [line 4803]

int getDayOfWeek( )

Gets the day of the week for this date (0 = Sunday)
  • Return: the day of the week (0 = Sunday)
  • Access: public

[ Top ]

getDayOfYear   [line 4788]

int getDayOfYear( )

Returns the no of days (1-366) since 31st December of the previous year
  • Return: an integer between 1 and 366
  • Since: Method available since Release 1.5.0
  • Access: public

[ Top ]

getDaysInMonth   [line 4848]

int getDaysInMonth( )

Gets number of days in the month for this date
  • Return: number of days in this month
  • Access: public

[ Top ]

getHour   [line 5172]

int getHour( )

Returns the hour field of the date object
  • Return: the hour
  • Access: public

[ Top ]

getJulianDate   [line 4772]

int getJulianDate( )

Returns the no of days (1-366) since 31st December of the previous year

N.B. this function does not return (and never has returned) the 'Julian Date', as described, for example, at:

If you want the day of the year (0-366), use Date::getDayOfYear() instead. If you want the true Julian Day, call one of the following:

There currently is no function that calls the Julian Date (as opposed to the 'Julian Day'), although the Julian Day is an approximation.

  • Return: the Julian date
  • See: Date::getDayOfYear()
  • Deprecated: Method deprecated in Release 1.5.0
  • Access: public

[ Top ]

getMinute   [line 5190]

int getMinute( )

Returns the minute field of the date object
  • Return: the minute
  • Access: public

[ Top ]

getMonth   [line 5027]

int getMonth( )

Returns the month field of the date object
  • Return: the minute
  • Access: public

[ Top ]

getMonthName   [line 4907]

string getMonthName( [boolean $abbr = false])

Gets the full name or abbreviated name of this month
  • Return: name of this month
  • Access: public

Parameters:

boolean   $abbr     abbreviate the name

[ Top ]

getNextDay   [line 4928]

object Date getNextDay( )

Get a Date object for the day after this one

The time of the returned Date object is the same as this time.

  • Return: object representing the next day
  • Access: public

[ Top ]

getNextWeekday   [line 4966]

object Date getNextWeekday( )

Get a Date object for the weekday after this one

The time of the returned Date object is the same as this time.

  • Return: object representing the next week-day
  • Access: public

[ Top ]

getPartSecond   [line 5249]

float getPartSecond( )

Returns the part-second field of the date object
  • Return: the part-second
  • Since: Method available since Release 1.5.0
  • Access: protected

[ Top ]

getPrevDay   [line 4947]

object Date getPrevDay( )

Get a Date object for the day before this one

The time of the returned Date object is the same as this time.

  • Return: object representing the previous day
  • Access: public

[ Top ]

getPrevWeekday   [line 4990]

object Date getPrevWeekday( )

Get a Date object for the weekday before this one

The time of the returned Date object is the same as this time.

  • Return: object representing the previous week-day
  • Access: public

[ Top ]

getQuarterOfYear   [line 4833]

int getQuarterOfYear( )

Gets the quarter of the year for this date
  • Return: the quarter of the year (1-4)
  • Access: public

[ Top ]

getSecond   [line 5208]

int getSecond( )

Returns the second field of the date object
  • Return: the second
  • Access: public

[ Top ]

getSecondsPastMidnight   [line 5227]

float getSecondsPastMidnight( )

Returns the no of seconds since midnight (0-86400) as float
  • Return: float which is at least 0 and less than 86400
  • Since: Method available since Release 1.5.0
  • Access: public

[ Top ]

getStandardDay   [line 5306]

int getStandardDay( )

Returns the day field of the local standard time
  • Return: the day
  • Since: Method available since Release 1.5.0
  • Access: public

[ Top ]

getStandardHour   [line 5325]

int getStandardHour( )

Returns the hour field of the local standard time
  • Return: the hour
  • Since: Method available since Release 1.5.0
  • Access: public

[ Top ]

getStandardMinute   [line 5344]

int getStandardMinute( )

Returns the minute field of the local standard time
  • Return: the minute
  • Since: Method available since Release 1.5.0
  • Access: public

[ Top ]

getStandardMonth   [line 5287]

int getStandardMonth( )

Returns the month field of the local standard time
  • Return: the minute
  • Since: Method available since Release 1.5.0
  • Access: public

[ Top ]

getStandardPartSecond   [line 5405]

float getStandardPartSecond( )

Returns the part-second field of the local standard time
  • Return: the part-second
  • Since: Method available since Release 1.5.0
  • Access: protected

[ Top ]

getStandardSecond   [line 5363]

int getStandardSecond( )

Returns the second field of the local standard time
  • Return: the second
  • Since: Method available since Release 1.5.0
  • Access: public

[ Top ]

getStandardSecondsPastMidnight   [line 5383]

float getStandardSecondsPastMidnight( )

Returns the no of seconds since midnight (0-86400) of the local standard time as float
  • Return: float which is at least 0 and less than 86400
  • Since: Method available since Release 1.5.0
  • Access: public

[ Top ]

getStandardYear   [line 5268]

int getStandardYear( )

Returns the year field of the local standard time
  • Return: the year
  • Since: Method available since Release 1.5.0
  • Access: public

[ Top ]

getTime   [line 3482]

int getTime( )

Returns the date/time as Unix time-stamp (as returned for example by time())

This may only be valid for dates from 1970 to ~2038. N.B. this function makes a call to gmmktime()

  • Return: number of seconds since the Unix epoch
  • Access: public

[ Top ]

getTZID   [line 3515]

string getTZID( )

Returns the unique ID of the time zone, e.g. 'America/Chicago'

[ Top ]

getTZLongName   [line 3699]

string getTZLongName( )

Returns the long name of the time zone

Returns long form of time zone name, e.g. 'Greenwich Mean Time'. N.B. if the date falls in Summer time, the Summer time name will be returned instead, e.g. 'British Summer Time'.

N.B. this is not a unique identifier for the time zone - for this purpose use the time zone ID.


[ Top ]

getTZOffset   [line 3762]

int getTZOffset( )

Returns the DST-corrected offset from UTC for the given date

Gets the offset to UTC for a given date/time, taking into account daylight savings time, if the time zone observes it and if it is in effect.

N.B. that the offset is calculated historically and in the future according to the current Summer time rules, and so this function is proleptically correct, but not necessarily historically correct. (Although if you want to be correct about times in the distant past, this class is probably not for you because the whole notion of time zones does not apply, and historically there are so many time zone changes, Summer time rule changes, name changes, calendar changes, that calculating this sort of information is beyond the scope of this package altogether.)

  • Return: the corrected offset to UTC in milliseconds
  • See: Date_TimeZone::getOffset()
  • Since: Method available since Release 1.5.0
  • Access: public

[ Top ]

getTZShortName   [line 3727]

string getTZShortName( )

Returns the short name of the time zone

Returns abbreviated form of time zone name, e.g. 'GMT'. N.B. if the date falls in Summer time, the Summer time name will be returned instead, e.g. 'BST'.

N.B. this is not a unique identifier - for this purpose use the time zone ID.


[ Top ]

getWeekOfYear   [line 4818]

int getWeekOfYear( )

Gets the week of the year for this date
  • Return: the week of the year
  • Access: public

[ Top ]

getWeeksInMonth   [line 4863]

int getWeeksInMonth( )

Gets the number of weeks in the month for this date
  • Return: number of weeks in this month
  • Access: public

[ Top ]

getYear   [line 5012]

int getYear( )

Returns the year field of the date object
  • Return: the year
  • Access: public

[ Top ]

inDaylightTime   [line 3787]

boolean inDaylightTime( [bool $pb_repeatedhourdefault = false])

Tests if this date/time is in DST

Returns true if daylight savings time is in effect for this date in this date's time zone.


Parameters:

bool   $pb_repeatedhourdefault     value to return if repeated hour is specified (defaults to false)

[ Top ]

inEquivalentTimeZones   [line 4551]

bool inEquivalentTimeZones( object $po_date1, object $po_date2)

Tests whether two dates are in equivalent time zones

Equivalence in this context consists in the time zones of the two dates having:

  • an equal offset from UTC in both standard and Summer time (if the time zones observe Summer time)
  • the same Summer time start and end rules, that is, the two time zones must switch from standard time to Summer time, and vice versa, on the same day and at the same time
An example of two equivalent time zones is 'Europe/London' and 'Europe/Lisbon', which in London is known as GMT/BST, and in Lisbon as WET/WEST.


Parameters:

object   $po_date1     the first Date object to compare
object   $po_date2     the second Date object to compare

[ Top ]

isFuture   [line 4709]

boolean isFuture( )

Determine if this date is in the future
  • Return: true if this date is in the future
  • Access: public

[ Top ]

isLeapYear   [line 4741]

boolean isLeapYear( )

Determine if the year in this date is a leap year
  • Return: true if this year is a leap year
  • Access: public

[ Top ]

isNull   [line 578]

bool isNull( )

Returns whether the object is null (i.e. no date has been set)

If the object is set to an invalid date, then this function will still return 'false'. To check whether the date is valid use either Date::isValidDate() (to check the day/month/year part of the object only) or Date::isValidTime() (to check the time, in addition to the day/month/year part).


[ Top ]

isPast   [line 4725]

boolean isPast( )

Determine if this date is in the past
  • Return: true if this date is in the past
  • Access: public

[ Top ]

isValidDate   [line 613]

bool isValidDate( )

Returns whether the date (i.e. day/month/year) is valid

It is not possible to set the object to an invalid date using Date::setDate(), but it is possible to do so using the following functions:

However you can prevent this possibility (by default) by setting DATE_VALIDATE_DATE_BY_DEFAULT to 'true', in which case these three functions will return an error if they specify an invalid date, and the object will be unmodified.

Note that this function only checks the day/month/year part of the object. Even if this is valid, it is still possible for the time to be invalid (see DATE_CORRECTINVALIDTIME_DEFAULT). To check the time as well, use Date::isValidTime().


[ Top ]

isValidTime   [line 5157]

bool isValidTime( )

Returns whether the stored date/time is valid, i.e as a local time for the current time-zone.

An invalid time is one that lies in the 'skipped hour' at the point that the clocks go forward (if the time-zone uses Summer time).

Note that the stored date (i.e. the day/month/year), is set more strictly: it is not possible to set an invalid day/month/year using Date::setDate() and it is only possible to do so with setYear() etc. for backwards-compatibility (and anyway, this can be switched off by default by setting DATE_VALIDATE_DATE_BY_DEFAULT to 'true').

The object is able to store an invalid time because a user might unwittingly and correctly store a valid time, and then add one day so as to put the object in the 'skipped' hour (when the clocks go forward). This could be corrected by a conversion to Summer time (by adding one hour); however, if the user then added another day, and had no need for or interest in the time anyway, the behaviour may be rather unexpected. And anyway in this situation, the time originally specified would now, two days on, be valid again.

So this class allows an invalid time like this so long as the user does not in any way make use of or request the time while it is in this semi-invalid state, in order to allow for for the fact that he might be only interested in the date, and not the time, and in order not to behave in an unexpected way, especially without throwing an exception to tell the user about it.


[ Top ]

round   [line 893]

void round( [int $pn_precision = DATE_PRECISION_DAY], [bool $pb_correctinvalidtime = DATE_CORRECTINVALIDTIME_DEFAULT])

Rounds the date according to the specified precision (defaults to nearest day)

The precision parameter must be one of the following constants:

The precision can also be specified as an integral offset from one of these constants, where the offset reflects a precision of 10 to the power of the offset greater than the constant. For example:

  • (DATE_PRECISION_YEAR - 1) - rounds the date to the nearest 10 years
  • (DATE_PRECISION_YEAR - 3) - rounds the date to the nearest 1000 years
  • (DATE_PRECISION_SECOND + 1) - rounds the date to 1 decimal point of a second
  • (DATE_PRECISION_SECOND + 3) - rounds the date to 3 decimal points of a second
  • (DATE_PRECISION_SECOND - 1) - rounds the date to the nearest 10 seconds (thus it is equivalent to DATE_PRECISION_10SECONDS)

  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_precision     a 'DATE_PRECISION_*' constant (defaults to DATE_PRECISION_DAY)
bool   $pb_correctinvalidtime     whether to correct, by adding the local Summer time offset, the rounded time if it falls in the skipped hour (defaults to DATE_CORRECTINVALIDTIME_DEFAULT)

[ Top ]

roundSeconds   [line 1041]

void roundSeconds( [int $pn_precision = 0], [bool $pb_correctinvalidtime = DATE_CORRECTINVALIDTIME_DEFAULT])

Rounds seconds up or down to the nearest specified unit

N.B. this function is equivalent to calling:

  1. $date_object->round(DATE_PRECISION_SECOND + $pn_precision);

  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_precision     number of digits after the decimal point
bool   $pb_correctinvalidtime     whether to correct, by adding the local Summer time offset, the rounded time if it falls in the skipped hour (defaults to DATE_CORRECTINVALIDTIME_DEFAULT)

[ Top ]

setDate   [line 716]

void setDate( string $date, [int $format = DATE_FORMAT_ISO], [bool $pb_repeatedhourdefault = false])

Sets the date/time of the object based on the input date and format

Accepts a string in three possible formats, and in this order of precedence:

Note that if you want to pass a Unix time-stamp then you need to set the $format parameter to DATE_FORMAT_UNIXTIME, or else use the method Date::setFromTime().

The input string should be a date/time representation in one of the following general formats:

  • <date>T<time><time-zone>
  • <date> <time><time-zone> (non-ISO-standard)
  • <date><time><time-zone> (non-ISO-standard)
  • <date>T<time> i.e. without optional <time-zone> representation
  • <date> <time>
  • <date><time>
  • <date> i.e. without optional <time> representation
that is, the representation must be comprised of a <date> part, with an optional <time> part, which itself may include an optional <time-zone> part, each of which may consist of any one of the permitted formats detailed below. The <date> and <time representations should be divided with the time designator T according to the ISO 8601 standard, although this method also permits representations divided by a space, or by no delimiter at all.

The <date> representation should be in one of the following formats:

  • Calendar date: YYYY-MM-DD (extended format) or YYYYMMDD (basic format), where [YYYY] indicates the four-digit year (0000-9999), [MM] indicates the month (01-12) and [DD] indicates the day of the month [01-31]
  • ISO week date: YYYY-Www-D (extended format) or YYYYWwwD (basic format), where [YYYY] indicates the ISO year (slightly different from the calendar year (see below)), [Www] indicates the ISO week no prefixed by the letter 'W' (W01-W53) and [D] indicates the ISO week-day (1-7), beginning on Monday and ending on Sunday. (Also see http://en.wikipedia.org/wiki/ISO_week_date.)
  • Ordinal date: YYYY-DDD (extended format) or YYYYDDD (basic format), where [YYYY] indicates the four-digit year (0000-9999) and [DDD] indicates the day of the year (001-366)
The <time> representation should be in one of the following formats:

  • hh:mm:ss (extended format) or hhmmss (basic format)
  • hh:mm (extended format) or hhmm (basic format)
  • hh (extended format) or hh (basic format)
where [hh] represents the hour (00-24), [mm] represents the minute (00-59) and [ss] represents the second (00-60)

Format parameter should be one of the specified DATE_FORMAT_* constants:


Parameters:

string   $date     input date
int   $format     optional format constant (DATE_FORMAT_*) of the input date. This parameter is not needed, except to force the setting of the date from a Unix time-stamp (for which use DATE_FORMAT_UNIXTIME). (Defaults to DATE_FORMAT_ISO.)
bool   $pb_repeatedhourdefault     value to return if repeated hour is specified (defaults to false)

[ Top ]

setDateTime   [line 6117]

void setDateTime( int $pn_day, int $pn_month, int $pn_year, int $pn_hour, int $pn_minute, mixed $pm_second, [bool $pb_repeatedhourdefault = false])

Sets all the fields of the date object (day, month, year, hour, minute and second)

If specified year forms an invalid date, then PEAR error will be returned. Note that setting each of these fields separately may unintentionally return a PEAR error if a transitory date is invalid between setting these fields.

N.B. if the repeated hour, due to the clocks going back, is specified, the default is to assume local standard time.


Parameters:

int   $pn_day     the day
int   $pn_month     the month
int   $pn_year     the year
int   $pn_hour     the hour
int   $pn_minute     the minute
mixed   $pm_second     the second as integer or float
bool   $pb_repeatedhourdefault     whether to assume Summer time if a repeated hour is specified (defaults to false)

[ Top ]

setDay   [line 5847]

void setDay( int $d, [bool $pb_validate = DATE_VALIDATE_DATE_BY_DEFAULT])

Sets the day field of the date object

If specified year forms an invalid date, then PEAR error will be returned, unless the validation is over-ridden using the second parameter.


Parameters:

int   $d     the day
bool   $pb_validate     whether to check that the new date is valid (defaults to DATE_VALIDATE_DATE_BY_DEFAULT)

[ Top ]

setDayMonthYear   [line 5889]

void setDayMonthYear( int $d, int $m, int $y)

Sets the day, month and year fields of the date object

If specified year forms an invalid date, then PEAR error will be returned. Note that setting each of these fields separately may unintentionally return a PEAR error if a transitory date is invalid between setting these fields.


Parameters:

int   $d     the day
int   $m     the month
int   $y     the year

[ Top ]

setFromTime   [line 3446]

void setFromTime( int $pn_timestamp)

Sets the date/time using a Unix time-stamp

This may only be valid for dates from 1970 to ~2038. N.B. this function makes a call to gmdate()


Parameters:

int   $pn_timestamp     Unix time-stamp

[ Top ]

setHour   [line 5928]

void setHour( int $h, [bool $pb_repeatedhourdefault = false])

Sets the hour field of the date object

Expects an hour in 24-hour format.


Parameters:

int   $h     the hour
bool   $pb_repeatedhourdefault     whether to assume Summer time if a repeated hour is specified (defaults to false)

[ Top ]

setHourMinuteSecond   [line 6064]

void setHourMinuteSecond( int $h, int $m, mixed $s, [bool $pb_repeatedhourdefault = false])

Sets the hour, minute, second and part-second fields of the date object

N.B. if the repeated hour, due to the clocks going back, is specified, the default is to assume local standard time.


Parameters:

int   $h     the hour
int   $m     the minute
mixed   $s     the second as integer or float
bool   $pb_repeatedhourdefault     whether to assume Summer time if a repeated hour is specified (defaults to false)

[ Top ]

setLocalTime   [line 5548]

void setLocalTime( int $pn_day, int $pn_month, int $pn_year, int $pn_hour, int $pn_minute, int $pn_second, float $pn_partsecond, [bool $pb_repeatedhourdefault = false], [bool $pb_correctinvalidtime = DATE_CORRECTINVALIDTIME_DEFAULT])

Sets local time (Summer-time-adjusted) and then calculates local standard time

Parameters:

int   $pn_day     the day
int   $pn_month     the month
int   $pn_year     the year
int   $pn_hour     the hour
int   $pn_minute     the minute
int   $pn_second     the second
float   $pn_partsecond     the part-second
bool   $pb_repeatedhourdefault     whether to assume Summer time if a repeated hour is specified (defaults to false)
bool   $pb_correctinvalidtime     whether to correct, by adding the local Summer time offset, the specified time if it falls in the skipped hour (defaults to DATE_CORRECTINVALIDTIME_DEFAULT)

[ Top ]

setMinute   [line 5961]

void setMinute( int $m, [bool $pb_repeatedhourdefault = false])

Sets the minute field of the date object

Parameters:

int   $m     the minute
bool   $pb_repeatedhourdefault     whether to assume Summer time if a repeated hour is specified (defaults to false)

[ Top ]

setMonth   [line 5807]

void setMonth( int $m, [bool $pb_validate = DATE_VALIDATE_DATE_BY_DEFAULT])

Sets the month field of the date object

If specified year forms an invalid date, then PEAR error will be returned, unless the validation is over-ridden using the second parameter.


Parameters:

int   $m     the month
bool   $pb_validate     whether to check that the new date is valid (defaults to DATE_VALIDATE_DATE_BY_DEFAULT)

[ Top ]

setNow   [line 830]

void setNow( [bool $pb_setmicrotime = DATE_CAPTURE_MICROTIME_BY_DEFAULT])

Sets to local current time and time zone
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

bool   $pb_setmicrotime     whether to set micro-time (defaults to the value of the constant DATE_CAPTURE_MICROTIME_BY_DEFAULT)

[ Top ]

setPartSecond   [line 6027]

void setPartSecond( float $pn_ps, [bool $pb_repeatedhourdefault = false])

Sets the part-second field of the date object

Parameters:

float   $pn_ps     the part-second
bool   $pb_repeatedhourdefault     whether to assume Summer time if a repeated hour is specified (defaults to false)

[ Top ]

setSecond   [line 5994]

void setSecond( mixed $s, [bool $pb_repeatedhourdefault = false])

Sets the second field of the date object

Parameters:

mixed   $s     the second as integer or float
bool   $pb_repeatedhourdefault     whether to assume Summer time if a repeated hour is specified (defaults to false)

[ Top ]

setStandardTime   [line 5688]

void setStandardTime( int $pn_day, int $pn_month, int $pn_year, int $pn_hour, int $pn_minute, int $pn_second, float $pn_partsecond)

Sets local standard time and then calculates local time (i.e.

Summer-time-adjusted)


Parameters:

int   $pn_day     the day
int   $pn_month     the month
int   $pn_year     the year
int   $pn_hour     the hour
int   $pn_minute     the minute
int   $pn_second     the second
float   $pn_partsecond     the part-second

[ Top ]

setTZ   [line 3577]

void setTZ( object $tz)

Sets the time zone of this Date

Sets the time zone of this date with the given Date_TimeZone object. Does not alter the date/time, only assigns a new time zone. For conversion, use Date::convertTZ().


Parameters:

object   $tz     the Date_TimeZone object to use. If called with a parameter that is not a Date_TimeZone object, will fall through to setTZByID().

[ Top ]

setTZByID   [line 3642]

void setTZByID( [string $ps_id = null])

Sets the time zone of this date with the given time zone ID

The time zone IDs are drawn from the 'tz data-base' (see http://en.wikipedia.org/wiki/Zoneinfo), which is the de facto internet and IT standard. (There is no official standard, and the tz data-base is not intended to be a regulating body anyway.) Lists of valid IDs are maintained at:

If no time-zone is specified and PHP version >= 5.1.0, the time zone is set automatically to the output of date_default_timezone_get() if set and valid, else the value returned by 'date("e")' if valid, else the default specified if the global constant '$GLOBALS["_DATE_TIMEZONE_DEFAULT"]', which if itself left unset, defaults to "UTC".

N.B. this function preserves the local date and time, that is, whether in local Summer time or local standard time. For example, if the time is set to 11.00 Summer time, and the time zone is then set to another time zone, using this function, in which the date falls in standard time, then the time will remain set to 11.00 UTC, and not 10.00. You can convert a date to another time zone by calling 'Date::convertTZ()', which preserves the actual time as measured against UTC.

The ID can also be specified as a UTC offset in one of the following forms, i.e. an offset with no geographical or political base:

  • UTC[+/-][h] - e.g. UTC-1 (the preferred form)
  • UTC[+/-][hh] - e.g. UTC+03
  • UTC[+/-][hh][mm] - e.g. UTC-0530
  • UTC[+/-][hh]:[mm] - e.g. UTC+03:00
N.B. 'UTC' seems to be technically preferred over 'GMT'. GMT-based IDs still exist in the tz data-base, but beware of POSIX-style offsets which are the opposite way round to what people normally expect.


Parameters:

string   $ps_id     a valid time zone id, e.g. 'Europe/London'

[ Top ]

setYear   [line 5767]

void setYear( int $y, [bool $pb_validate = DATE_VALIDATE_DATE_BY_DEFAULT])

Sets the year field of the date object

If specified year forms an invalid date, then PEAR error will be returned, unless the validation is over-ridden using the second parameter.


Parameters:

int   $y     the year
bool   $pb_validate     whether to check that the new date is valid (defaults to DATE_VALIDATE_DATE_BY_DEFAULT)

[ Top ]

subtractSeconds   [line 4273]

void subtractSeconds( mixed $sec, [bool $pb_countleap = null])

Subtracts a given number of seconds from the date
  • Access: public

Parameters:

mixed   $sec     the no of seconds to subtract as integer or float
bool   $pb_countleap     whether to count leap seconds (defaults to value of count-leap-second object property)

[ Top ]

subtractSpan   [line 4407]

void subtractSpan( object $span)

Subtracts a time span from the date

N.B. it is impossible for this function to count leap seconds, because the result would be dependent on which order the consituent parts of the span are subtracted from the date. Therefore, leap seconds are ignored by this function. If you want to count leap seconds, use Date::subtractSeconds().


Parameters:

object   $span     the time span to subtract

[ Top ]

toUTC   [line 3873]

void toUTC( )

Converts this date to UTC and sets this date's timezone to UTC

[ Top ]

trunc   [line 1100]

void trunc( [int $pn_precision = DATE_PRECISION_DAY], [bool $pb_correctinvalidtime = DATE_CORRECTINVALIDTIME_DEFAULT])

Truncates the date according to the specified precision (by default, it truncates the time part of the date)

The precision parameter must be one of the following constants:

The precision can also be specified as an integral offset from one of these constants, where the offset reflects a precision of 10 to the power of the offset greater than the constant. For example:

  • DATE_PRECISION_YEAR - truncates the month, day and time part of the year
  • (DATE_PRECISION_YEAR - 1) - truncates the unit part of the year, e.g. 1987 becomes 1980
  • (DATE_PRECISION_YEAR - 3) - truncates the hundreds part of the year, e.g. 1987 becomes 1000
  • (DATE_PRECISION_SECOND + 1) - truncates the part of the second less than 0.1 of a second, e.g. 3.26301 becomes 3.2 seconds
  • (DATE_PRECISION_SECOND + 3) - truncates the part of the second less than 0.001 of a second, e.g. 3.26301 becomes 3.263 seconds
  • (DATE_PRECISION_SECOND - 1) - truncates the unit part of the seconds (thus it is equivalent to DATE_PRECISION_10SECONDS)

  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_precision     a 'DATE_PRECISION_*' constant (defaults to DATE_PRECISION_DAY)
bool   $pb_correctinvalidtime     whether to correct, by adding the local Summer time offset, the truncated time if it falls in the skipped hour (defaults to DATE_CORRECTINVALIDTIME_DEFAULT)

[ Top ]

truncSeconds   [line 1222]

void truncSeconds( [int $pn_precision = 0], [bool $pb_correctinvalidtime = DATE_CORRECTINVALIDTIME_DEFAULT])

Truncates seconds according to the specified precision

N.B. this function is equivalent to calling:

  1.    $date_object->trunc(DATE_PRECISION_SECOND + $pn_precision);

  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_precision     number of digits after the decimal point
bool   $pb_correctinvalidtime     whether to correct, by adding the local Summer time offset, the truncated time if it falls in the skipped hour (defaults to DATE_CORRECTINVALIDTIME_DEFAULT)

[ Top ]

__clone   [line 550]

void __clone( )

Copy values from another Date object

Makes this Date a copy of another Date object. For PHP5 only.


[ Top ]


Documentation generated on Tue, 08 Oct 2013 05:30:21 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.