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 PhpOffice\PhpSpreadsheet\Calculation\Exception; 6 7 class Month 8 { 9 /** 10 * EDATE. 11 * 12 * Returns the serial number that represents the date that is the indicated number of months 13 * before or after a specified date (the start_date). 14 * Use EDATE to calculate maturity dates or due dates that fall on the same day of the month 15 * as the date of issue. 16 * 17 * Excel Function: 18 * EDATE(dateValue,adjustmentMonths) 19 * 20 * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), 21 * PHP DateTime object, or a standard date string 22 * @param int $adjustmentMonths The number of months before or after start_date. 23 * A positive value for months yields a future date; 24 * a negative value yields a past date. 25 * 26 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, 27 * depending on the value of the ReturnDateType flag 28 */ 29 public static function adjust($dateValue, $adjustmentMonths) 30 { 31 try { 32 $dateValue = Helpers::getDateValue($dateValue, false); 33 $adjustmentMonths = Helpers::validateNumericNull($adjustmentMonths); 34 } catch (Exception $e) { 35 return $e->getMessage(); 36 } 37 $adjustmentMonths = floor($adjustmentMonths); 38 39 // Execute function 40 $PHPDateObject = Helpers::adjustDateByMonths($dateValue, $adjustmentMonths); 41 42 return Helpers::returnIn3FormatsObject($PHPDateObject); 43 } 44 45 /** 46 * EOMONTH. 47 * 48 * Returns the date value for the last day of the month that is the indicated number of months 49 * before or after start_date. 50 * Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month. 51 * 52 * Excel Function: 53 * EOMONTH(dateValue,adjustmentMonths) 54 * 55 * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), 56 * PHP DateTime object, or a standard date string 57 * @param int $adjustmentMonths The number of months before or after start_date. 58 * A positive value for months yields a future date; 59 * a negative value yields a past date. 60 * 61 * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, 62 * depending on the value of the ReturnDateType flag 63 */ 64 public static function lastDay($dateValue, $adjustmentMonths) 65 { 66 try { 67 $dateValue = Helpers::getDateValue($dateValue, false); 68 $adjustmentMonths = Helpers::validateNumericNull($adjustmentMonths); 69 } catch (Exception $e) { 70 return $e->getMessage(); 71 } 72 $adjustmentMonths = floor($adjustmentMonths); 73 74 // Execute function 75 $PHPDateObject = Helpers::adjustDateByMonths($dateValue, $adjustmentMonths + 1); 76 $adjustDays = (int) $PHPDateObject->format('d'); 77 $adjustDaysString = '-' . $adjustDays . ' days'; 78 $PHPDateObject->modify($adjustDaysString); 79 80 return Helpers::returnIn3FormatsObject($PHPDateObject); 81 } 82 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body