Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel; 4 5 use DateTimeInterface; 6 use PhpOffice\PhpSpreadsheet\Calculation\Exception; 7 use PhpOffice\PhpSpreadsheet\Calculation\Functions; 8 use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper; 9 10 class Days 11 { 12 /** 13 * DAYS. 14 * 15 * Returns the number of days between two dates 16 * 17 * Excel Function: 18 * DAYS(endDate, startDate) 19 * 20 * @param DateTimeInterface|float|int|string $endDate Excel date serial value (float), 21 * PHP date timestamp (integer), PHP DateTime object, or a standard date string 22 * @param DateTimeInterface|float|int|string $startDate Excel date serial value (float), 23 * PHP date timestamp (integer), PHP DateTime object, or a standard date string 24 * 25 * @return int|string Number of days between start date and end date or an error 26 */ 27 public static function between($endDate, $startDate) 28 { 29 try { 30 $startDate = Helpers::getDateValue($startDate); 31 $endDate = Helpers::getDateValue($endDate); 32 } catch (Exception $e) { 33 return $e->getMessage(); 34 } 35 36 // Execute function 37 $PHPStartDateObject = SharedDateHelper::excelToDateTimeObject($startDate); 38 $PHPEndDateObject = SharedDateHelper::excelToDateTimeObject($endDate); 39 40 $days = Functions::VALUE(); 41 $diff = $PHPStartDateObject->diff($PHPEndDateObject); 42 if ($diff !== false && !is_bool($diff->days)) { 43 $days = $diff->days; 44 if ($diff->invert) { 45 $days = -$days; 46 } 47 } 48 49 return $days; 50 } 51 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body