You are here

public static function PHPExcel_Shared_Date::FormattedPHPToExcel in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/Date.php \PHPExcel_Shared_Date::FormattedPHPToExcel()

* FormattedPHPToExcel * *

Parameters

long $year: * @param long $month * @param long $day * @param long $hours * @param long $minutes * @param long $seconds * @return long Excel date/time value

9 calls to PHPExcel_Shared_Date::FormattedPHPToExcel()
10autofilter-selection-1.php in vendor/phpoffice/phpexcel/Examples/10autofilter-selection-1.php
10autofilter-selection-2.php in vendor/phpoffice/phpexcel/Examples/10autofilter-selection-2.php
10autofilter-selection-display.php in vendor/phpoffice/phpexcel/Examples/10autofilter-selection-display.php
PHPExcel_Calculation_DateTime::DATE in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php
* DATE * * 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. PHPExcel does not change…
PHPExcel_Calculation_DateTime::DATEVALUE in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php
* DATEVALUE * * Returns a value that represents a particular date. * Use DATEVALUE to convert a date represented by a text string to an Excel or PHP date/time stamp * value. * * NOTE: When used in a Cell Formula, MS Excel changes the cell…

... See full list

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/Date.php, line 215

Class

PHPExcel_Shared_Date
PHPExcel_Shared_Date

Code

public static function FormattedPHPToExcel($year, $month, $day, $hours = 0, $minutes = 0, $seconds = 0) {
  if (self::$_excelBaseDate == self::CALENDAR_WINDOWS_1900) {

    //
    //	Fudge factor for the erroneous fact that the year 1900 is treated as a Leap Year in MS Excel
    //	This affects every date following 28th February 1900
    //
    $excel1900isLeapYear = TRUE;
    if ($year == 1900 && $month <= 2) {
      $excel1900isLeapYear = FALSE;
    }
    $my_excelBaseDate = 2415020;
  }
  else {
    $my_excelBaseDate = 2416481;
    $excel1900isLeapYear = FALSE;
  }

  //	Julian base date Adjustment
  if ($month > 2) {
    $month -= 3;
  }
  else {
    $month += 9;
    --$year;
  }

  //	Calculate the Julian Date, then subtract the Excel base date (JD 2415020 = 31-Dec-1899 Giving Excel Date of 0)
  $century = substr($year, 0, 2);
  $decade = substr($year, 2, 2);
  $excelDate = floor(146097 * $century / 4) + floor(1461 * $decade / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $my_excelBaseDate + $excel1900isLeapYear;
  $excelTime = ($hours * 3600 + $minutes * 60 + $seconds) / 86400;
  return (double) $excelDate + $excelTime;
}