Date
in package
uses
ArrayEnabled
Table of Contents
Properties
Methods
- fromYMD() : array<string|int, mixed>|DateTime|float|int|string
- DATE.
- evaluateArrayArguments() : array<string|int, mixed>
- Handles array argument processing when the function accepts multiple arguments, and any of them can be an array argument.
- evaluateArrayArgumentsIgnore() : array<string|int, mixed>
- Handles array argument processing when the function accepts multiple arguments, and any of them can be an array argument except for the one specified by ignore.
- evaluateArrayArgumentsSubset() : array<string|int, mixed>
- Handles array argument processing when the function accepts multiple arguments, but only the first few (up to limit) can be an array arguments.
- evaluateArrayArgumentsSubsetFrom() : array<string|int, mixed>
- Handles array argument processing when the function accepts multiple arguments, but only the last few (from start) can be an array arguments.
- evaluateSingleArgumentArray() : array<string|int, mixed>
- Handles array argument processing when the function accepts a single argument that can be an array argument.
- adjustYearMonth() : void
- getDay() : int
- Convert day from multiple formats to int.
- getMonth() : int
- Convert month from multiple formats to int.
- getYear() : int
- Convert year from multiple formats to int.
- initialiseHelper() : void
- testFalse() : bool
Properties
$arrayArgumentHelper
private
static ArrayArgumentHelper
$arrayArgumentHelper
$initializationNeeded
private
static bool
$initializationNeeded
= true
Methods
fromYMD()
DATE.
public
static fromYMD(array<string|int, mixed>|float|int|string $year, array<string|int, mixed>|float|int|string $month, array<string|int, mixed>|float|int|string $day) : array<string|int, mixed>|DateTime|float|int|string
The DATE function returns a value that represents a particular date.
NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date format of your regional settings. PhpSpreadsheet does not change cell formatting in this way.
Excel Function: DATE(year,month,day)
PhpSpreadsheet is a lot more forgiving than MS Excel when passing non numeric values to this function. A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted, as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language.
Parameters
- $year : array<string|int, mixed>|float|int|string
-
The value of the year argument can include one to four digits. Excel interprets the year argument according to the configured date system: 1900 or 1904. If year is between 0 (zero) and 1899 (inclusive), Excel adds that value to 1900 to calculate the year. For example, DATE(108,1,2) returns January 2, 2008 (1900+108). If year is between 1900 and 9999 (inclusive), Excel uses that value as the year. For example, DATE(2008,1,2) returns January 2, 2008. If year is less than 0 or is 10000 or greater, Excel returns the #NUM! error value.
- $month : array<string|int, mixed>|float|int|string
-
A positive or negative integer representing the month of the year from 1 to 12 (January to December). If month is greater than 12, month adds that number of months to the first month in the year specified. For example, DATE(2008,14,2) returns the serial number representing February 2, 2009. If month is less than 1, month subtracts the magnitude of that number of months, plus 1, from the first month in the year specified. For example, DATE(2008,-3,2) returns the serial number representing September 2, 2007.
- $day : array<string|int, mixed>|float|int|string
-
A positive or negative integer representing the day of the month from 1 to 31. If day is greater than the number of days in the month specified, day adds that number of days to the first day in the month. For example, DATE(2008,1,35) returns the serial number representing February 4, 2008. If day is less than 1, day subtracts the magnitude that number of days, plus one, from the first day of the month specified. For example, DATE(2008,1,-15) returns the serial number representing December 16, 2007.
Return values
array<string|int, mixed>|DateTime|float|int|string —Excel date/time serial value, PHP date/time serial value or PHP date/time object, depending on the value of the ReturnDateType flag If an array of numbers is passed as the argument, then the returned result will also be an array with the same dimensions
evaluateArrayArguments()
Handles array argument processing when the function accepts multiple arguments, and any of them can be an array argument.
protected
static evaluateArrayArguments(callable $method, mixed ...$arguments) : array<string|int, mixed>
Example use for: ROUND() or DATE().
Parameters
- $method : callable
- $arguments : mixed
Return values
array<string|int, mixed>evaluateArrayArgumentsIgnore()
Handles array argument processing when the function accepts multiple arguments, and any of them can be an array argument except for the one specified by ignore.
protected
static evaluateArrayArgumentsIgnore(callable $method, int $ignore, mixed ...$arguments) : array<string|int, mixed>
Example use for: HLOOKUP() and VLOOKUP(), where argument 1 is a matrix that needs to be treated as a database rather than as an array argument.
Parameters
- $method : callable
- $ignore : int
- $arguments : mixed
Return values
array<string|int, mixed>evaluateArrayArgumentsSubset()
Handles array argument processing when the function accepts multiple arguments, but only the first few (up to limit) can be an array arguments.
protected
static evaluateArrayArgumentsSubset(callable $method, int $limit, mixed ...$arguments) : array<string|int, mixed>
Example use for: NETWORKDAYS() or CONCATENATE(), where the last argument is a matrix (or a series of values) that need to be treated as a such rather than as an array arguments.
Parameters
- $method : callable
- $limit : int
- $arguments : mixed
Return values
array<string|int, mixed>evaluateArrayArgumentsSubsetFrom()
Handles array argument processing when the function accepts multiple arguments, but only the last few (from start) can be an array arguments.
protected
static evaluateArrayArgumentsSubsetFrom(callable $method, int $start, mixed ...$arguments) : array<string|int, mixed>
Example use for: Z.TEST() or INDEX(), where the first argument 1 is a matrix that needs to be treated as a dataset rather than as an array argument.
Parameters
- $method : callable
- $start : int
- $arguments : mixed
Return values
array<string|int, mixed>evaluateSingleArgumentArray()
Handles array argument processing when the function accepts a single argument that can be an array argument.
protected
static evaluateSingleArgumentArray(callable $method, array<string|int, mixed> $values) : array<string|int, mixed>
Example use for: DAYOFMONTH() or FACT().
Parameters
- $method : callable
- $values : array<string|int, mixed>
Return values
array<string|int, mixed>adjustYearMonth()
private
static adjustYearMonth(int &$year, int &$month, int $baseYear) : void
Parameters
- $year : int
- $month : int
- $baseYear : int
getDay()
Convert day from multiple formats to int.
private
static getDay(mixed $day) : int
Parameters
- $day : mixed
Return values
intgetMonth()
Convert month from multiple formats to int.
private
static getMonth(mixed $month) : int
Parameters
- $month : mixed
Return values
intgetYear()
Convert year from multiple formats to int.
private
static getYear(mixed $year, int $baseYear) : int
Parameters
- $year : mixed
- $baseYear : int
Return values
intinitialiseHelper()
private
static initialiseHelper(array<string|int, mixed>|false $arguments) : void
Parameters
- $arguments : array<string|int, mixed>|false
-
Can be changed to array for Php8.1+
testFalse()
private
static testFalse(mixed $value) : bool
Parameters
- $value : mixed