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

Class: Date_Calc

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

Class Overview


Calculates, manipulates and retrieves dates


Author(s):

Version:

  • Release: 1.5.0a1

Copyright:

  • 1999-2007 Monte Ohrt, Pierre-Alain Joye, Daniel Convissor, C.A. Woodcock

Methods


Inherited Variables

Inherited Methods


Class Details

[line 117]
Calculates, manipulates and retrieves dates

It does not rely on 32-bit system time stamps, so it works dates before 1970 and after 2038.



[ Top ]


Method Detail

addDays   [line 1553]

string addDays( int $pn_days, int $pn_day, int $pn_month, int $pn_year, [string $ps_format = DATE_CALC_FORMAT])

Returns the date the specified no of days from the given date

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

  • Return: the date in the desired format
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_days   —  days to add
int   $pn_day   —  the day of the month, default is current local day
int   $pn_month   —  the month, default is current local month
int   $pn_year   —  the year in four digit format, default is current local year
string   $ps_format   —  string specifying how to format the output

[ Top ]

addHours   [line 694]

array addHours( int $pn_hours, int $pn_day, int $pn_month, int $pn_year, int $pn_hour)

Returns the date the specified no of hours from the given date

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

  • Return: array of year, month, day, hour
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_hours   —  hours to add
int   $pn_day   —  the day of the month
int   $pn_month   —  the month
int   $pn_year   —  the year
int   $pn_hour   —  the hour

[ Top ]

addMinutes   [line 751]

array addMinutes( int $pn_minutes, int $pn_day, int $pn_month, int $pn_year, int $pn_hour, int $pn_minute)

Returns the date the specified no of minutes from the given date

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

  • Return: array of year, month, day, hour, minute
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_minutes   —  minutes to add
int   $pn_day   —  the day of the month
int   $pn_month   —  the month
int   $pn_year   —  the year
int   $pn_hour   —  the hour
int   $pn_minute   —  the minute

[ Top ]

addMonths   [line 1384]

string addMonths( int $pn_months, int $pn_day, int $pn_month, int $pn_year, [string $ps_format = DATE_CALC_FORMAT])

Returns the date the specified no of months from the given date

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

  • Return: the date in the desired format
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_months   —  months to add
int   $pn_day   —  the day of the month, default is current local day
int   $pn_month   —  the month, default is current local month
int   $pn_year   —  the year in four digit format, default is current local year
string   $ps_format   —  string specifying how to format the output

[ Top ]

addMonthsToDays   [line 1323]

int addMonthsToDays( int $pn_months, int $pn_days)

Returns 'Julian Day' of the date the specified no of months from the given date

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

  • Return: 'Julian Day', i.e. the no of days since 1st January, 4713 B.C.
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_months   —  months to add
int   $pn_days   —  'Julian Day', i.e. the no of days since 1st January, 4713 B.C.

[ Top ]

addSeconds   [line 822]

array addSeconds( mixed $pn_seconds, int $pn_day, int $pn_month, int $pn_year, int $pn_hour, int $pn_minute, mixed $pn_second, [bool $pb_countleap = DATE_COUNT_LEAP_SECONDS])

Returns the date the specified no of seconds from the given date

If leap seconds are specified to be counted, the passed time must be UTC. To subtract seconds use a negative value for the '$pn_seconds' parameter.

N.B. the return type of the second part of the date is float if either '$pn_seconds' or '$pn_second' is a float; otherwise, it is integer.

  • Return: array of year, month, day, hour, minute, second
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

mixed   $pn_seconds   —  seconds to add as integer or float
int   $pn_day   —  the day of the month
int   $pn_month   —  the month
int   $pn_year   —  the year
int   $pn_hour   —  the hour
int   $pn_minute   —  the minute
mixed   $pn_second   —  the second as integer or float
bool   $pb_countleap   —  whether to count leap seconds (defaults to DATE_COUNT_LEAP_SECONDS)

[ Top ]

addYears   [line 1503]

string addYears( int $pn_years, int $pn_day, int $pn_month, int $pn_year, [string $ps_format = DATE_CALC_FORMAT])

Returns the date the specified no of years from the given date

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

  • Return: the date in the desired format
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_years   —  years to add
int   $pn_day   —  the day of the month, default is current local day
int   $pn_month   —  the month, default is current local month
int   $pn_year   —  the year in four digit format, default is current local year
string   $ps_format   —  string specifying how to format the output

[ Top ]

addYearsToDays   [line 1433]

int addYearsToDays( int $pn_years, int $pn_days)

Returns 'Julian Day' of the date the specified no of years from the given date

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

  • Return: 'Julian Day', i.e. the no of days since 1st January, 4713 B.C.
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_years   —  years to add
int   $pn_days   —  'Julian Day', i.e. the no of days since 1st January, 4713 B.C.

[ Top ]

beginOfMonth   [line 3447]

string beginOfMonth( [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Return date of first day of month of given date

Parameters:

int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

beginOfMonthBySpan   [line 3668]

string beginOfMonthBySpan( [int $months = 0], [string $month = 0], [string $year = null], [string $format = DATE_CALC_FORMAT])

Returns date of the first day of the month in the number of months from the given date
  • Return: the date in the desired format
  • Since: Method available since Release 1.4.4
  • Access: public

Parameters:

int   $months   —  the number of months from the date provided. Positive numbers go into the future. Negative numbers go into the past. Nought is the month presented in $month.
string   $month   —  the month, default is current local month
string   $year   —  the year in four digit format, default is the current local year
string   $format   —  the string indicating how to format the output

[ Top ]

beginOfNextMonth   [line 3589]

string beginOfNextMonth( [mixed $dummy = null], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Returns date of begin of next month of given date

Parameters:

mixed   $dummy   —  irrelevant parameter
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

beginOfNextWeek   [line 3404]

string beginOfNextWeek( [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Find the month day of the beginning of week after given date, using DATE_CALC_BEGIN_WEEKDAY

Can return weekday of prev month.

  • Return: the date in the desired format
  • Access: public

Parameters:

int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

beginOfPrevMonth   [line 3514]

string beginOfPrevMonth( [mixed $dummy = null], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Returns date of the first day of previous month of given date

Parameters:

mixed   $dummy   —  irrelevant parameter
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

beginOfPrevWeek   [line 3360]

string beginOfPrevWeek( [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Find the month day of the beginning of week before given date, using DATE_CALC_BEGIN_WEEKDAY

Can return weekday of prev month.

  • Return: the date in the desired format
  • Access: public

Parameters:

int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

beginOfWeek   [line 3282]

string beginOfWeek( [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Find the month day of the beginning of week for given date, using DATE_CALC_BEGIN_WEEKDAY

Can return weekday of prev month.

  • Return: the date in the desired format
  • Access: public

Parameters:

int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

compareDates   [line 4069]

int compareDates( int $day1, int $month1, int $year1, int $day2, int $month2, int $year2)

Compares two dates
  • Return: 0 if the dates are equal. 1 if date 1 is later, -1 if date 1 is earlier.
  • Access: public

Parameters:

int   $day1   —  the day of the month
int   $month1   —  the month
int   $year1   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.
int   $day2   —  the day of the month
int   $month2   —  the month
int   $year2   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.

[ Top ]

dateDiff   [line 4036]

int dateDiff( int $day1, int $month1, int $year1, int $day2, int $month2, int $year2)

Returns number of days between two given dates
  • Return: the absolute number of days between the two dates. If an error occurs, -1 is returned.
  • Access: public

Parameters:

int   $day1   —  the day of the month
int   $month1   —  the month
int   $year1   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.
int   $day2   —  the day of the month
int   $month2   —  the month
int   $year2   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.

[ Top ]

dateFormat   [line 162]

string dateFormat( int $day, int $month, int $year, string $format)

Formats the date in the given format, much like strftime()

This function is used to alleviate the problem with 32-bit numbers for dates pre 1970 or post 2038, as strftime() has on most systems. Most of the formatting options are compatible.

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)
  • %d - day of month (range 00 to 31)
  • %e - day of month, single digit (range 0 to 31)
  • %E - number of days since unspecified epoch (integer). ('%E' is useful for passing a date in a URL as an integer value. Then simply use Date_Calc::daysToDate() to convert back to a date.)
  • %j - day of year (range 001 to 366)
  • %m - month as decimal number (range 1 to 12)
  • %n - newline character (\n)
  • %t - tab character (\t)
  • %w - weekday as decimal (0 = Sunday)
  • %U - week number of current year, first sunday as first week
  • %y - year as decimal (range 00 to 99)
  • %Y - year as decimal including century (range 0000 to 9999)
  • %% - literal '%'

  • Return: the date in the desired format
  • Access: public

Parameters:

int   $day   —  the day of the month
int   $month   —  the month
int   $year   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.
string   $format   —  the format string

[ Top ]

dateNow   [line 259]

string dateNow( [string $format = DATE_CALC_FORMAT])

Returns the current local date

NOTE: This function retrieves the local date using strftime(), which may or may not be 32-bit safe on your system.

  • Return: the current date in the specified format
  • Access: public

Parameters:

string   $format   —  the string indicating how to format the output

[ Top ]

dateSeason   [line 2115]

float dateSeason( string $season, [string $year = 0])

Determines julian date of the given season
  • Return: the julian date the season starts on
  • Access: public

Parameters:

string   $season   —  the season to get the date for: VERNALEQUINOX, SUMMERSOLSTICE, AUTUMNALEQUINOX, or WINTERSOLSTICE
string   $year   —  the year in four digit format. Must be between -1000 B.C. and 3000 A.D.

[ Top ]

dateToDays   [line 1109]

int dateToDays( int $day, int $month, int $year)

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

Returns the no of days since Monday, 24th November, 4714 B.C. in the proleptic Gregorian calendar (which is 24th November, -4713 using 'Astronomical' year numbering, and 1st January, 4713 B.C. in the proleptic Julian calendar). This is also the first day of the 'Julian Period' proposed by Joseph Scaliger in 1583, and the number of days since this date is known as the 'Julian Day'. (It is not directly to do with the Julian calendar, although this is where the name is derived from.)

The algorithm is valid for all years (positive and negative), and also for years preceding 4714 B.C.

  • Return: the number of days since 24th November, 4714 B.C.
  • Access: public

Parameters:

int   $day   —  the day of the month
int   $month   —  the month
int   $year   —  the year (using 'Astronomical' year numbering)

[ Top ]

dateToDaysJulian   [line 1759]

int dateToDaysJulian( int $day, int $month, int $year)

Converts a date in the proleptic Julian calendar to the no of days since 1st January, 4713 B.C.

Returns the no of days since Monday, 1st January, 4713 B.C. in the proleptic Julian calendar (which is 1st January, -4712 using 'Astronomical' year numbering, and 24th November, 4713 B.C. in the proleptic Gregorian calendar). This is also the first day of the 'Julian Period' proposed by Joseph Scaliger in 1583, and the number of days since this date is known as the 'Julian Day'. (It is not directly to do with the Julian calendar, although this is where the name is derived from.)

The algorithm is valid for all years (positive and negative), and also for years preceding 4713 B.C.

  • Return: the number of days since 1st January, 4713 B.C.
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $day   —  the day of the month
int   $month   —  the month
int   $year   —  the year (using 'Astronomical' year numbering)

[ Top ]

dayOfWeek   [line 2434]

int dayOfWeek( [int $day = null], [int $month = null], [int $year = null])

Returns day of week for given date (0 = Sunday)

The algorithm is valid for all years (positive and negative).

  • Return: the number of the day in the week
  • Access: public

Parameters:

int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year

[ Top ]

dayOfYear   [line 2173]

int dayOfYear( [int $pn_day = 0], [int $pn_month = 0], [int $pn_year = null])

Returns number of days since 31 December of year before given date
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_day   —  the day of the month, default is current local day
int   $pn_month   —  the month, default is current local month
int   $pn_year   —  the year in four digit format, default is current local year

[ Top ]

daysInMonth   [line 2676]

int daysInMonth( [int $month = 0], [int $year = null])

Returns the number of days in the given month
  • Return: the number of days the month has
  • Access: public

Parameters:

int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year

[ Top ]

daysInYear   [line 2704]

int daysInYear( [int $year = null])

Returns the number of days in the given year
  • Return: the number of days the year has
  • Access: public

Parameters:

int   $year   —  the year in four digit format, default is current local year

[ Top ]

daysToDate   [line 1168]

string daysToDate( int $days, [string $format = DATE_CALC_FORMAT])

Converts no of days since 24th November, 4714 B.C. (in the proleptic Gregorian calendar, which is year -4713 using 'Astronomical' year numbering) to Gregorian calendar date

Returned date belongs to the proleptic Gregorian calendar, using 'Astronomical' year numbering.

The algorithm is valid for all years (positive and negative), and also for years preceding 4714 B.C. (i.e. for negative 'Julian Days'), and so the only limitation is platform-dependent (for 32-bit systems the maximum year would be something like about 1,465,190 A.D.).

N.B. Monday, 24th November, 4714 B.C. is Julian Day '0'.

  • Return: the date in the desired format
  • Access: public

Parameters:

int   $days   —  the number of days since 24th November, 4714 B.C.
string   $format   —  the string indicating how to format the output

[ Top ]

daysToDateJulian   [line 1808]

string daysToDateJulian( int $days, [string $format = DATE_CALC_FORMAT])

Converts no of days since 1st January, 4713 B.C. (in the proleptic Julian calendar, which is year -4712 using 'Astronomical' year numbering) to Julian calendar date

Returned date belongs to the proleptic Julian calendar, using 'Astronomical' year numbering.

  • Return: the date in the desired format
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $days   —  the number of days since 1st January, 4713 B.C.
string   $format   —  the string indicating how to format the output

[ Top ]

daysToDayOfWeek   [line 2408]

int daysToDayOfWeek( int $pn_days)

Returns day of week for specified 'Julian Day'

The algorithm is valid for all years (positive and negative), and also for years preceding 4714 B.C. (i.e. for negative 'Julian Days'), and so the only limitation is platform-dependent (for 32-bit systems the maximum year would be something like about 1,465,190 A.D.).

N.B. Monday, 24th November, 4714 B.C. is Julian Day '0'.

  • Return: integer from 0 to 7 where 0 represents Sunday
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_days   —  the number of days since 24th November, 4714 B.C.

[ Top ]

daysToNextDayOfWeek   [line 3137]

int daysToNextDayOfWeek( int $dow, int $days, [bool $onorafter = false])

Returns 'Julian Day' of the next specific day of the week from the given date.
  • Return: 'Julian Day', i.e. the no of days since 1st January, 4713 B.C.
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $dow   —  the day of the week (0 = Sunday)
int   $days   —  'Julian Day', i.e. the no of days since 1st January, 4713 B.C.
bool   $onorafter   —  if true and days are same, returns current day

[ Top ]

daysToPrevDayOfWeek   [line 3059]

int daysToPrevDayOfWeek( int $dow, int $days, [bool $onorbefore = false])

Returns 'Julian Day' of the previous specific day of the week from the given date.
  • Return: 'Julian Day', i.e. the no of days since 1st January, 4713 B.C.
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $dow   —  the day of the week (0 = Sunday)
int   $days   —  'Julian Day', i.e. the no of days since 1st January, 4713 B.C.
bool   $onorbefore   —  if true and days are same, returns current day

[ Top ]

defaultCentury   [line 339]

int defaultCentury( int $year)

Turns a two digit year into a four digit year

Return value depends on current year; the century chosen will be the one which forms the year that is closest to the current year. If the two possibilities are equidistant to the current year (i.e. 50 years in the past and 50 years in the future), then the past year is chosen.

For example, if the current year is 2007:

  • "03" - returns 2003
  • "09" - returns 2009
  • "56" - returns 2056 (closer to 2007 than 1956)
  • "57" - returns 1957 (1957 and 2007 are equidistant, so previous century chosen)
  • "58" - returns 1958

  • Return: the 4 digit year
  • Access: public

Parameters:

int   $year   —  the 2 digit year

[ Top ]

endOfMonth   [line 3482]

string endOfMonth( [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Return date of last day of month of given date
  • Return: the date in the desired format
  • See: Date_Calc::beginOfMonthBySpan()
  • Deprecated: Method deprecated in Release 1.5.0
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

endOfMonthBySpan   [line 3709]

string endOfMonthBySpan( [int $months = 0], [string $month = 0], [string $year = null], [string $format = DATE_CALC_FORMAT])

Returns date of the last day of the month in the number of months from the given date
  • Return: the date in the desired format
  • Since: Method available since Release 1.4.4
  • Access: public

Parameters:

int   $months   —  the number of months from the date provided. Positive numbers go into the future. Negative numbers go into the past. Nought is the month presented in $month.
string   $month   —  the month, default is current local month
string   $year   —  the year in four digit format, default is the current local year
string   $format   —  the string indicating how to format the output

[ Top ]

endOfNextMonth   [line 3628]

string endOfNextMonth( [mixed $dummy = null], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Returns date of the last day of next month of given date

Parameters:

mixed   $dummy   —  irrelevant parameter
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

endOfPrevMonth   [line 3553]

string endOfPrevMonth( [mixed $dummy = null], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Returns date of the last day of previous month for given date

Parameters:

mixed   $dummy   —  irrelevant parameter
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

endOfWeek   [line 3321]

string endOfWeek( [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Find the month day of the end of week for given date, using DATE_CALC_BEGIN_WEEKDAY

Can return weekday of following month.

  • Return: the date in the desired format
  • Access: public

Parameters:

int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

firstDayOfMonth   [line 1638]

integer firstDayOfMonth( int $pn_month, int $pn_year)

Returns the Julian Day of the first day of the month of the specified year (i.e. the no of days since 24th November, 4714 B.C.)
  • Return: the number of days since 24th November, 4714 B.C.
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_month   —  the month
int   $pn_year   —  the year (using 'Astronomical' year numbering)

[ Top ]

firstDayOfYear   [line 1704]

integer firstDayOfYear( int $pn_year)

Returns the Julian Day of the first day of the year (i.e. the no of days since 24th November, 4714 B.C.)
  • Return: the number of days since 24th November, 4714 B.C.
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_year   —  the year (using 'Astronomical' year numbering)

[ Top ]

firstOfMonthWeekday   [line 3741]

int firstOfMonthWeekday( [int $month = 0], [int $year = null])

Find the day of the week for the first of the month of given date
  • Return: number of weekday for the first day, 0=Sunday
  • Access: public

Parameters:

int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year

[ Top ]

getCalendarMonth   [line 2815]

array getCalendarMonth( [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Return a set of arrays to construct a calendar month for the given date
  • Access: public

Parameters:

int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

getCalendarWeek   [line 2773]

array getCalendarWeek( [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Return an array with days in week
  • Access: public

Parameters:

int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

getCalendarYear   [line 2870]

array getCalendarYear( [int $year = null], [string $format = DATE_CALC_FORMAT])

Return a set of arrays to construct a calendar year for the given date
  • Access: public

Parameters:

int   $year   —  the year in four digit format, default current local year
string   $format   —  the string indicating how to format the output

[ Top ]

getDay   [line 307]

string getDay( )

Returns the current local day in format DD
  • Return: the current day of the month in two digit format
  • Access: public

[ Top ]

getFirstDayOfMonth   [line 1597]

int getFirstDayOfMonth( int $pn_month, int $pn_year)

Returns first day of the specified month of specified year as integer
  • Return: number of first day of month
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_month   —  the month
int   $pn_year   —  the year (using 'Astronomical' year numbering)

[ Top ]

getFirstMonthOfYear   [line 1683]

int getFirstMonthOfYear( int $pn_year)

Returns first month of specified year as integer
  • Return: number of first month of year
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_year   —  the year (using 'Astronomical' year numbering)

[ Top ]

getLastDayOfMonth   [line 1617]

int getLastDayOfMonth( int $pn_month, int $pn_year)

Returns last day of the specified month of specified year as integer
  • Return: number of last day of month
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_month   —  the month
int   $pn_year   —  the year (using 'Astronomical' year numbering)

[ Top ]

getMonth   [line 291]

string getMonth( )

Returns the current local month in format MM
  • Return: the current month in two digit format
  • Access: public

[ Top ]

getMonthAbbrname   [line 2322]

string getMonthAbbrname( int $month, [int $length = 3])

Returns the abbreviated month name for the given month
  • Return: the abbreviated name of the month
  • See: Date_Calc::getMonthFullname
  • Access: public

Parameters:

int   $month   —  the month
int   $length   —  the length of abbreviation

[ Top ]

getMonthFromFullName   [line 2349]

int getMonthFromFullName( string $month)

Returns the numeric month from the month name or an abreviation

Both August and Aug would return 8.

  • Return: the month's number
  • Access: public

Parameters:

string   $month   —  the name of the month to examine. Case insensitive.

[ Top ]

getMonthFullname   [line 2296]

string getMonthFullname( int $month)

Returns the full month name for the given month
  • Return: the full name of the month
  • Access: public

Parameters:

int   $month   —  the month

[ Top ]

getMonthNames   [line 1238]

array getMonthNames( [int $pb_abbreviated = false])

Returns an array of month names

Used to take advantage of the setlocale function to return language specific month names.

TODO: cache values to some global array to avoid performance hits when called more than once.

  • Return: associative array of integer month numbers, in order, to month names
  • Access: public

Parameters:

int   $pb_abbreviated   —  whether to return the abbreviated form of the months

[ Top ]

getMonths   [line 1210]

array getMonths( int $pn_year)

Returns array of the month numbers, in order, for the given year
  • Return: array of integer month numbers, in order
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_year   —  the year (using 'Astronomical' year numbering)

[ Top ]

getSecondsInDay   [line 486]

int getSecondsInDay( int $pn_day, int $pn_month, int $pn_year)

Returns the total number of seconds in the day of the given date

This takes into account leap seconds.

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

Parameters:

int   $pn_day   —  the day of the month
int   $pn_month   —  the month
int   $pn_year   —  the year in four digit format

[ Top ]

getSecondsInHour   [line 561]

int getSecondsInHour( int $pn_day, int $pn_month, int $pn_year, int $pn_hour)

Returns the total number of seconds in the hour of the given date

This takes into account leap seconds.

  • Access: public

Parameters:

int   $pn_day   —  the day of the month
int   $pn_month   —  the month
int   $pn_year   —  the year in four digit format
int   $pn_hour   —  the hour

[ Top ]

getSecondsInMinute   [line 590]

int getSecondsInMinute( int $pn_day, int $pn_month, int $pn_year, int $pn_hour, int $pn_minute)

Returns the total number of seconds in the minute of the given hour

This takes into account leap seconds.

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

Parameters:

int   $pn_day   —  the day of the month
int   $pn_month   —  the month
int   $pn_year   —  the year in four digit format
int   $pn_hour   —  the hour
int   $pn_minute   —  the minute

[ Top ]

getSecondsInMonth   [line 427]

int getSecondsInMonth( int $pn_month, int $pn_year)

Returns the total number of seconds in the given month

This takes into account leap seconds.

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

Parameters:

int   $pn_month   —  the month
int   $pn_year   —  the year in four digit format

[ Top ]

getSecondsInYear   [line 371]

int getSecondsInYear( int $pn_year)

Returns the total number of seconds in the given year

This takes into account leap seconds.

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

Parameters:

int   $pn_year   —  the year in four digit format

[ Top ]

getWeekdayAbbrname   [line 2263]

string getWeekdayAbbrname( [int $pn_day = 0], [int $pn_month = 0], [int $pn_year = null], [int $length = 3])

Returns the abbreviated weekday name for the given date

Parameters:

int   $pn_day   —  the day of the month, default is current local day
int   $pn_month   —  the month, default is current local month
int   $pn_year   —  the year in four digit format, default is current local year
int   $length   —  the length of abbreviation

[ Top ]

getWeekdayFullname   [line 2228]

string getWeekdayFullname( [int $pn_day = 0], [int $pn_month = 0], [int $pn_year = null])

Returns the full weekday name for the given date
  • Return: the full name of the day of the week
  • Access: public

Parameters:

int   $pn_day   —  the day of the month, default is current local day
int   $pn_month   —  the month, default is current local month
int   $pn_year   —  the year in four digit format, default is current local year

[ Top ]

getWeekDays   [line 2378]

array getWeekDays( [int $pb_abbreviated = false])

Returns an array of week day names

Used to take advantage of the setlocale function to return language specific week days.

  • Return: an array of week-day names
  • Access: public

Parameters:

int   $pb_abbreviated   —  whether to return the abbreviated form of the days

[ Top ]

getYear   [line 275]

string getYear( )

Returns the current local year in format CCYY
  • Return: the current year in four digit format
  • Access: public

[ Top ]

gregorianToISO   [line 1940]

string gregorianToISO( int $day, int $month, int $year)

Converts from Gregorian Year-Month-Day to ISO Year-WeekNumber-WeekDay

Uses ISO 8601 definitions.

  • Return: the date in ISO Year-WeekNumber-WeekDay format
  • Access: public

Parameters:

int   $day   —  the day of the month
int   $month   —  the month
int   $year   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.

[ Top ]

isFutureDate   [line 3959]

bool isFutureDate( int $day, int $month, int $year)

Determines if given date is a future date from now
  • Access: public

Parameters:

int   $day   —  the day of the month
int   $month   —  the month
int   $year   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.

[ Top ]

isLeapYear   [line 3929]

boolean isLeapYear( [int $year = null])

Returns true for a leap year, else false
  • Access: public

Parameters:

int   $year   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.

[ Top ]

isLeapYearGregorian   [line 3878]

bool isLeapYearGregorian( [int $year = null])

Returns true for a leap year, else false

Uses the proleptic Gregorian calendar. The year 0 (1 B.C.) is assumed in this algorithm to be a leap year. The function is valid for all years, positive and negative.

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

Parameters:

int   $year   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.

[ Top ]

isLeapYearJulian   [line 3907]

boolean isLeapYearJulian( [int $year = null])

Returns true for a leap year, else false

Uses the proleptic Julian calendar. The year 0 (1 B.C.) is assumed in this algorithm to be a leap year. The function is valid for all years, positive and negative.

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

Parameters:

int   $year   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.

[ Top ]

isoWeekDate   [line 1858]

array isoWeekDate( [int $pn_day = 0], [int $pn_month = 0], [int $pn_year = null])

Returns array defining the 'ISO Week Date' as defined in ISO 8601

Expects a date in the proleptic Gregorian calendar using 'Astronomical' year numbering, that is, with a year 0. Algorithm is valid for all years (positive and negative).

N.B. the ISO week day no for Sunday is defined as 7, whereas this class and its related functions defines Sunday as 0.

  • Return: array of ISO Year, ISO Week No, ISO Day No as integers
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_day   —  the day of the month
int   $pn_month   —  the month
int   $pn_year   —  the year

[ Top ]

isoWeekToDate   [line 4396]

string isoWeekToDate( int $dow, int $week, int $year, [string $format = DATE_CALC_FORMAT])

Converts the Week number and Day-of-Week to Date

Calculation algorithm taken from http://www.merlyn.demon.co.uk/weekcalc.htm.

  • Return: formatted date
  • Since: Method available since Release 1.5.0a2
  • Access: public

Parameters:

int   $dow   —  day of week from 1 (Monday) to 7 (Sunday)
int   $week   —  number of week from 1 to 53
int   $year   —  four digits of year
string   $format   —  the output format

[ Top ]

isPastDate   [line 3995]

boolean isPastDate( int $day, int $month, int $year)

Determines if given date is a past date from now
  • Access: public

Parameters:

int   $day   —  the day of the month
int   $month   —  the month
int   $year   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.

[ Top ]

isValidDate   [line 3842]

bool isValidDate( int $day, int $month, int $year)

Returns true for valid date, false for invalid date

Uses the proleptic Gregorian calendar, with the year 0 (1 B.C.) assumed to be valid and also assumed to be a leap year.

  • Access: public

Parameters:

int   $day   —  the day of the month
int   $month   —  the month
int   $year   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.

[ Top ]

julianDate   [line 2207]

int julianDate( [int $pn_day = 0], [int $pn_month = 0], [int $pn_year = null])

Returns number of days since 31 December of year before given date
  • Deprecated: Method deprecated in Release 1.5.0
  • Access: public

Parameters:

int   $pn_day   —  the day of the month, default is current local day
int   $pn_month   —  the month, default is current local month
int   $pn_year   —  the year in four digit format, default is current local year

[ Top ]

lastDayOfMonth   [line 1662]

integer lastDayOfMonth( int $pn_month, int $pn_year)

Returns the Julian Day of the last day of the month of the specified year (i.e. the no of days since 24th November, 4714 B.C.)
  • Return: the number of days since 24th November, 4714 B.C.
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_month   —  the month
int   $pn_year   —  the year (using 'Astronomical' year numbering)

[ Top ]

lastDayOfYear   [line 1725]

integer lastDayOfYear( int $pn_year)

Returns the Julian Day of the last day of the year (i.e. the no of days since 24th November, 4714 B.C.)
  • Return: the number of days since 24th November, 4714 B.C.
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_year   —  the year (using 'Astronomical' year numbering)

[ Top ]

nextDay   [line 2937]

string nextDay( [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Returns date of day after given date
  • Return: the date in the desired format
  • Access: public

Parameters:

int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

nextDayOfWeek   [line 3174]

string nextDayOfWeek( int $dow, [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT], [bool $onorafter = false])

Returns date of the next specific day of the week from the given date
  • Return: the date in the desired format
  • Access: public

Parameters:

int   $dow   —  the day of the week (0 = Sunday)
int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output
bool   $onorafter   —  if true and days are same, returns current day

[ Top ]

nextDayOfWeekOnOrAfter   [line 3248]

string nextDayOfWeekOnOrAfter( int $dow, [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Returns date of the next specific day of the week on or after the given date
  • Return: the date in the desired format
  • Access: public

Parameters:

int   $dow   —  the day of the week (0 = Sunday)
int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

nextMonth   [line 1290]

array nextMonth( int $pn_month, int $pn_year)

Returns month and year of next month
  • Return: array of year, month as integers
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_month   —  the month
int   $pn_year   —  the year (using 'Astronomical' year numbering)

[ Top ]

nextWeekday   [line 3015]

string nextWeekday( [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Returns date of the next weekday of given date, skipping from Friday to Monday
  • Return: the date in the desired format
  • Access: public

Parameters:

int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

nWeekDayOfMonth   [line 3773]

string nWeekDayOfMonth( int $week, int $dow, int $month, int $year, [string $format = DATE_CALC_FORMAT])

Calculates the date of the Nth weekday of the month, such as the second Saturday of January 2000
  • Return: the date in the desired format
  • Access: public

Parameters:

int   $week   —  the number of the week to get (1 to 5. Also can be 'last'.)
int   $dow   —  the day of the week (0 = Sunday)
int   $month   —  the month
int   $year   —  the year. Use the complete year instead of the abbreviated version. E.g. use 2005, not 05.
string   $format   —  the string indicating how to format the output

[ Top ]

prevDay   [line 2904]

string prevDay( [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Returns date of day before given date
  • Return: the date in the desired format
  • Access: public

Parameters:

int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

prevDayOfWeek   [line 3096]

string prevDayOfWeek( int $dow, [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT], [bool $onorbefore = false])

Returns date of the previous specific day of the week from the given date
  • Return: the date in the desired format
  • Access: public

Parameters:

int   $dow   —  the day of the week (0 = Sunday)
int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output
bool   $onorbefore   —  if true and days are same, returns current day

[ Top ]

prevDayOfWeekOnOrBefore   [line 3215]

string prevDayOfWeekOnOrBefore( int $dow, [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Returns date of the previous specific day of the week on or before the given date
  • Return: the date in the desired format
  • Access: public

Parameters:

int   $dow   —  the day of the week (0 = Sunday)
int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

prevMonth   [line 1263]

array prevMonth( int $pn_month, int $pn_year)

Returns month and year of previous month
  • Return: array of year, month as integers
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_month   —  the month
int   $pn_year   —  the year (using 'Astronomical' year numbering)

[ Top ]

prevWeekday   [line 2972]

string prevWeekday( [int $day = 0], [int $month = 0], [int $year = null], [string $format = DATE_CALC_FORMAT])

Returns date of the previous weekday, skipping from Monday to Friday
  • Return: the date in the desired format
  • Access: public

Parameters:

int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year
string   $format   —  the string indicating how to format the output

[ Top ]

quarterOfYear   [line 2653]

int quarterOfYear( [int $day = 0], [int $month = 0], [int $year = null])

Returns quarter of the year for given date
  • Return: the number of the quarter in the year
  • Access: public

Parameters:

int   $day   —  the day of the month, default is current local day
int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year

[ Top ]

round   [line 4134]

array round( int $pn_precision, int $pn_day, int $pn_month, int $pn_year, [int $pn_hour = 0], [int $pn_minute = 0], [mixed $pn_second = 0], [bool $pb_countleap = DATE_COUNT_LEAP_SECONDS])

Rounds the date according to the specified precision

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 + 1) 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)
N.B. This function requires a time in UTC if both the precision is at least DATE_PRECISION_SECOND and leap seconds are being counted, otherwise any local time is acceptable.

  • Return: array of year, month, day, hour, minute, second
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_precision   —  a 'DATE_PRECISION_*' constant (defaults to DATE_PRECISION_DAY)
int   $pn_day   —  the day of the month
int   $pn_month   —  the month
int   $pn_year   —  the year
int   $pn_hour   —  the hour
int   $pn_minute   —  the minute
mixed   $pn_second   —  the second as integer or float
bool   $pb_countleap   —  whether to count leap seconds (defaults to DATE_COUNT_LEAP_SECONDS)

[ Top ]

roundSeconds   [line 4358]

array roundSeconds( int $pn_precision, int $pn_day, int $pn_month, int $pn_year, int $pn_hour, int $pn_minute, mixed $pn_second, [bool $pb_countleap = DATE_COUNT_LEAP_SECONDS])

Rounds seconds up or down to the nearest specified unit
  • Return: array of year, month, day, hour, minute, second
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_precision   —  number of digits after the decimal point
int   $pn_day   —  the day of the month
int   $pn_month   —  the month
int   $pn_year   —  the year
int   $pn_hour   —  the hour
int   $pn_minute   —  the minute
mixed   $pn_second   —  the second as integer or float
bool   $pb_countleap   —  whether to count leap seconds (defaults to DATE_COUNT_LEAP_SECONDS)

[ Top ]

secondsPastMidnight   [line 619]

mixed secondsPastMidnight( int $pn_hour, int $pn_minute, mixed $pn_second)

Returns the no of seconds since midnight (0-86399)
  • Return: integer or float from 0-86399
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_hour   —  the hour of the day
int   $pn_minute   —  the minute
mixed   $pn_second   —  the second as integer or float

[ Top ]

secondsPastMidnightToTime   [line 639]

mixed secondsPastMidnightToTime( mixed $pn_seconds)

Returns the time as an array (i.e. hour, minute, second)
  • Return: array of hour, minute (both as integers), second (as integer or float, depending on parameter)
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

mixed   $pn_seconds   —  the no of seconds since midnight (0-86399)

[ Top ]

secondsPastTheHour   [line 669]

mixed secondsPastTheHour( int $pn_minute, mixed $pn_second)

Returns the no of seconds since the last hour o'clock (0-3599)
  • Return: integer or float from 0-3599
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_minute   —  the minute
mixed   $pn_second   —  the second as integer or float

[ Top ]

weekOfMonth   [line 2632]

int weekOfMonth( [int $pn_day = 0])

Alias for 'weekOfMonthAbsolute()'
  • Return: integer from 1 to 5
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_day   —  the day of the month, default is current local day

[ Top ]

weekOfMonthAbsolute   [line 2610]

int weekOfMonthAbsolute( [int $pn_day = 0])

Returns week of the month counting week 1 as 1st-7th of the month, regardless of what day the 1st falls on

Returned value is an integer from 1 to 5. Week 5 will start on the 29th of the month and have between 1 and 3 days, except in February in a non-leap year, when there will be 4 weeks only.

  • Return: integer from 1 to 5
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_day   —  the day of the month, default is current local day

[ Top ]

weekOfYear   [line 2585]

int weekOfYear( [int $pn_day = 0], [int $pn_month = 0], [int $pn_year = null])

Returns week of the year, where first Sunday is first day of first week

N.B. this function is equivalent to calling:

  1. Date_Calc::weekOfYear7th($day$month$year0);

Returned week is an integer from 1 to 53.

  • Return: integer from 1 to 53
  • See: Date_Calc::weekOfYear7th
  • Deprecated: Method deprecated in Release 1.5.0
  • Access: public

Parameters:

int   $pn_day   —  the day of the month, default is current local day
int   $pn_month   —  the month, default is current local month
int   $pn_year   —  the year in four digit format, default is current local year

[ Top ]

weekOfYear1st   [line 2541]

int weekOfYear1st( [int $pn_day = 0], [int $pn_month = 0], [int $pn_year = null], [int $pn_firstdayofweek = DATE_CALC_BEGIN_WEEKDAY])

Returns week of the year counting week 1 as the week that contains 1st January

Week 1 is determined to be the week that includes the 1st January, even if this week extends into the previous year, in which case the week will only contain between 1 and 6 days of the current year. Note that this definition depends on which day is the first day of the week, and that if this is not passed as the '$pn_firstdayofweek' parameter, the default is assumed.

Note also that the last day week of the year is also likely to contain less than seven days, except in the case that the last day of the week falls on 31st December.

Returned value is an integer from 1 to 54. The year will only contain 54 weeks in the case of a leap year in which 1st January is the last day of the week, and 31st December is the first day of the week. In this case, both weeks 1 and 54 will contain one day only.

  • Return: integer from 1 to 54
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_day   —  the day of the month, default is current local day
int   $pn_month   —  the month, default is current local month
int   $pn_year   —  the year in four digit format, default is current local year
int   $pn_firstdayofweek   —  optional integer specifying the first day of the week

[ Top ]

weekOfYear4th   [line 1993]

array weekOfYear4th( [int $pn_day = 0], [int $pn_month = 0], [int $pn_year = null], [int $pn_firstdayofweek = DATE_CALC_BEGIN_WEEKDAY])

Returns week of the year counting week 1 as the week that contains 4th January

Week 1 is determined to be the week that includes the 4th January, and therefore can be defined as the first week of the year that has at least 4 days. The previous week is counted as week 52 or 53 of the previous year. Note that this definition depends on which day is the first day of the week, and that if this is not passed as the '$pn_firstdayofweek' parameter, the default is assumed.

Note also that the last day week of the year is likely to extend into the following year, except in the case that the last day of the week falls on 31st December.

Also note that this is very similar to the ISO week returned by Date::isoWeekDate(), the difference being that the ISO week always has 7 days, and if the 4th of January is a Friday, for example, ISO week 1 would start on Monday, 31st December in the previous year, whereas the week defined by this function would start on 1st January, but would be only 6 days long. Of course you can also set the day of the week, whereas the ISO week starts on a Monday by definition.

Returned week is an integer from 1 to 53.

  • Return: array of year, week no as integers
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_day   —  the day of the month, default is current local day
int   $pn_month   —  the month, default is current local month
int   $pn_year   —  the year in four digit format, default is current local year
int   $pn_firstdayofweek   —  optional integer specifying the first day of the week

[ Top ]

weekOfYear7th   [line 2067]

array weekOfYear7th( [int $pn_day = 0], [int $pn_month = 0], [int $pn_year = null], [int $pn_firstdayofweek = DATE_CALC_BEGIN_WEEKDAY])

Returns week of the year counting week 1 as the week that contains 7th January

Week 1 is determined to be the week that includes the 7th January, and therefore can be defined as the first full week of the year. The previous week is counted as week 52 or 53 of the previous year. Note that this definition depends on which day is the first day of the week, and that if this is not passed as the '$pn_firstdayofweek' parameter, the default is assumed.

Note also that the last day week of the year is likely to extend into the following year, except in the case that the last day of the week falls on 31st December.

Returned week is an integer from 1 to 53.

  • Return: array of year, week no as integers
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_day   —  the day of the month, default is current local day
int   $pn_month   —  the month, default is current local month
int   $pn_year   —  the year in four digit format, default is current local year
int   $pn_firstdayofweek   —  optional integer specifying the first day of the week

[ Top ]

weekOfYearAbsolute   [line 2488]

int weekOfYearAbsolute( [int $pn_day = 0], [int $pn_month = 0], [int $pn_year = null])

Returns week of the year counting week 1 as 1st-7th January, regardless of what day 1st January falls on

Returned value is an integer from 1 to 53. Week 53 will start on 31st December and have only one day, except in a leap year, in which it will start a day earlier and contain two days.

  • Return: integer from 1 to 53
  • Since: Method available since Release 1.5.0
  • Access: public

Parameters:

int   $pn_day   —  the day of the month, default is current local day
int   $pn_month   —  the month, default is current local month
int   $pn_year   —  the year in four digit format, default is current local year

[ Top ]

weeksInMonth   [line 2732]

int weeksInMonth( [int $month = 0], [int $year = null])

Returns the number of rows on a calendar month

Useful for determining the number of rows when displaying a typical month calendar.

  • Return: the number of weeks the month has
  • Access: public

Parameters:

int   $month   —  the month, default is current local month
int   $year   —  the year in four digit format, default is current local year

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:55:00 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.