See Release Notes
Long Term Support Release
Differences Between: [Versions 400 and 401] [Versions 401 and 403]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel; 4 5 use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; 6 use PhpOffice\PhpSpreadsheet\Calculation\Exception; 7 8 class Month 9 { 10 use ArrayEnabled; 11 12 /** 13 * EDATE. 14 * 15 * Returns the serial number that represents the date that is the indicated number of months 16 * before or after a specified date (the start_date). 17 * Use EDATE to calculate maturity dates or due dates that fall on the same day of the month 18 * as the date of issue. 19 * 20 * Excel Function: 21 * EDATE(dateValue,adjustmentMonths) 22 * 23 * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), 24 * PHP DateTime object, or a standard date string 25 * Or can be an array of date values 26 * @param array|int $adjustmentMonths The number of months before or after start_date. 27 * A positive value for months yields a future date; 28 * a negative value yields a past date. 29 * Or can be an array of adjustment values 30 * 31 * @return array|mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, 32 * depending on the value of the ReturnDateType flag 33 * If an array of values is passed as the argument, then the returned result will also be an array 34 * with the same dimensions 35 */ 36 public static function adjust($dateValue, $adjustmentMonths) 37 { 38 if (is_array($dateValue) || is_array($adjustmentMonths)) { 39 return self::evaluateArrayArguments([self::class, __FUNCTION__], $dateValue, $adjustmentMonths); 40 } 41 42 try { 43 $dateValue = Helpers::getDateValue($dateValue, false); 44 $adjustmentMonths = Helpers::validateNumericNull($adjustmentMonths); 45 } catch (Exception $e) { 46 return $e->getMessage(); 47 } 48 $adjustmentMonths = floor($adjustmentMonths); 49 50 // Execute function 51 $PHPDateObject = Helpers::adjustDateByMonths($dateValue, $adjustmentMonths); 52 53 return Helpers::returnIn3FormatsObject($PHPDateObject); 54 } 55 56 /** 57 * EOMONTH. 58 * 59 * Returns the date value for the last day of the month that is the indicated number of months 60 * before or after start_date. 61 * Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month. 62 * 63 * Excel Function: 64 * EOMONTH(dateValue,adjustmentMonths) 65 * 66 * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), 67 * PHP DateTime object, or a standard date string 68 * Or can be an array of date values 69 * @param array|int $adjustmentMonths The number of months before or after start_date. 70 * A positive value for months yields a future date; 71 * a negative value yields a past date. 72 * Or can be an array of adjustment values 73 * 74 * @return array|mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, 75 * depending on the value of the ReturnDateType flag 76 * If an array of values is passed as the argument, then the returned result will also be an array 77 * with the same dimensions 78 */ 79 public static function lastDay($dateValue, $adjustmentMonths) 80 { 81 if (is_array($dateValue) || is_array($adjustmentMonths)) { 82 return self::evaluateArrayArguments([self::class, __FUNCTION__], $dateValue, $adjustmentMonths); 83 } 84 85 try { 86 $dateValue = Helpers::getDateValue($dateValue, false); 87 $adjustmentMonths = Helpers::validateNumericNull($adjustmentMonths); 88 } catch (Exception $e) { 89 return $e->getMessage(); 90 } 91 $adjustmentMonths = floor($adjustmentMonths); 92 93 // Execute function 94 $PHPDateObject = Helpers::adjustDateByMonths($dateValue, $adjustmentMonths + 1); 95 $adjustDays = (int) $PHPDateObject->format('d'); 96 $adjustDaysString = '-' . $adjustDays . ' days'; 97 $PHPDateObject->modify($adjustDaysString); 98 99 return Helpers::returnIn3FormatsObject($PHPDateObject); 100 } 101 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body