# tablepress/3.4/libraries/vendor/PhpSpreadsheet/Calculation/DateTimeExcel/Days.php

TablePress – Tables in WordPress made easy, version 3.4. 61 lines.

- Page: https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Calculation/DateTimeExcel/Days.php
- Raw: https://pluginprobe.com/plugins/tablepress/3.4/raw/libraries/vendor/PhpSpreadsheet/Calculation/DateTimeExcel/Days.php
- Modified: 2026-06-10T03:54:08+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Calculation/DateTimeExcel/Days.php#L10-L20`.

```php
<?php

namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel;

use DateTimeInterface;
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Exception;
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
use TablePress\PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper;

class Days
{
	use ArrayEnabled;

	/**
	 * DAYS.
	 *
	 * Returns the number of days between two dates
	 *
	 * Excel Function:
	 *        DAYS(endDate, startDate)
	 *
	 * @param array<mixed>|DateTimeInterface|float|int|string $endDate Excel date serial value (float),
	 *           PHP date timestamp (integer), PHP DateTime object, or a standard date string
	 *                         Or can be an array of date values
	 * @param array<mixed>|DateTimeInterface|float|int|string $startDate Excel date serial value (float),
	 *           PHP date timestamp (integer), PHP DateTime object, or a standard date string
	 *                         Or can be an array of date values
	 *
	 * @return array<mixed>|int|string Number of days between start date and end date or an error
	 *         If an array of values is passed for the $startDate or $endDays,arguments, then the returned result
	 *            will also be an array with matching dimensions
	 */
	public static function between($endDate, $startDate)
	{
		if (is_array($endDate) || is_array($startDate)) {
			return self::evaluateArrayArguments([self::class, __FUNCTION__], $endDate, $startDate);
		}

		try {
			$startDate = Helpers::getDateValue($startDate);
			$endDate = Helpers::getDateValue($endDate);
		} catch (Exception $e) {
			return $e->getMessage();
		}

		// Execute function
		$PHPStartDateObject = SharedDateHelper::excelToDateTimeObject($startDate);
		$PHPEndDateObject = SharedDateHelper::excelToDateTimeObject($endDate);

		$days = ExcelError::VALUE();
		$diff = $PHPStartDateObject->diff($PHPEndDateObject);
		$days = $diff->days;
		if ($diff->invert) {
			$days = -$days;
		}

		return $days;
	}
}

```
