You are here

public static function PHPExcel_Calculation_DateTime::TIMEVALUE in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php \PHPExcel_Calculation_DateTime::TIMEVALUE()

* TIMEVALUE * * Returns a value that represents a particular time. * Use TIMEVALUE to convert a time 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 format so that it matches the time * format of your regional settings. PHPExcel does not change cell formatting in this way. * * Excel Function: * TIMEVALUE(timeValue) * * @access public * @category Date/Time Functions *

Parameters

string $timeValue A text string that represents a time in any one of the Microsoft: * Excel time formats; for example, "6:45 PM" and "18:45" text strings * within quotation marks that represent time. * Date information in time_text is ignored. * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, * depending on the value of the ReturnDateType flag

5 calls to PHPExcel_Calculation_DateTime::TIMEVALUE()
DateTimeTest::testTIMEVALUEtoPHP in vendor/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/DateTimeTest.php
DateTimeTest::testTIMEVALUEtoPHPObject in vendor/phpoffice/phpexcel/unitTests/Classes/PHPExcel/Calculation/DateTimeTest.php
PHPExcel_Calculation_DateTime::_getTimeValue in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php
* _getTimeValue * *
PHPExcel_Calculation_TextData::VALUE in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/TextData.php
* VALUE * *
PHPExcel_Shared_Date::stringToExcel in vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/Date.php
* Convert a date/time string to Excel time * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/DateTime.php, line 583

Class

PHPExcel_Calculation_DateTime
PHPExcel_Calculation_DateTime

Code

public static function TIMEVALUE($timeValue) {
  $timeValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($timeValue), '"');
  $timeValue = str_replace(array(
    '/',
    '.',
  ), array(
    '-',
    '-',
  ), $timeValue);
  $PHPDateArray = date_parse($timeValue);
  if ($PHPDateArray !== False && $PHPDateArray['error_count'] == 0) {
    if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
      $excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'], $PHPDateArray['month'], $PHPDateArray['day'], $PHPDateArray['hour'], $PHPDateArray['minute'], $PHPDateArray['second']);
    }
    else {
      $excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel(1900, 1, 1, $PHPDateArray['hour'], $PHPDateArray['minute'], $PHPDateArray['second']) - 1;
    }
    switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
      case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
        return (double) $excelDateValue;
      case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC:
        return (int) ($phpDateValue = PHPExcel_Shared_Date::ExcelToPHP($excelDateValue + 25569) - 3600);
      case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT:
        return new DateTime('1900-01-01 ' . $PHPDateArray['hour'] . ':' . $PHPDateArray['minute'] . ':' . $PHPDateArray['second']);
    }
  }
  return PHPExcel_Calculation_Functions::VALUE();
}