You are here

public static function PHPExcel_Shared_Date::stringToExcel in Loft Data Grids 6.2

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

* Convert a date/time string to Excel time * *

Parameters

string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10': * @return float|FALSE Excel date/time serial value

1 call to PHPExcel_Shared_Date::stringToExcel()
PHPExcel_Cell_AdvancedValueBinder::bindValue in vendor/phpoffice/phpexcel/Classes/PHPExcel/Cell/AdvancedValueBinder.php
Bind value to a cell

File

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

Class

PHPExcel_Shared_Date
PHPExcel_Shared_Date

Code

public static function stringToExcel($dateValue = '') {
  if (strlen($dateValue) < 2) {
    return FALSE;
  }
  if (!preg_match('/^(\\d{1,4}[ \\.\\/\\-][A-Z]{3,9}([ \\.\\/\\-]\\d{1,4})?|[A-Z]{3,9}[ \\.\\/\\-]\\d{1,4}([ \\.\\/\\-]\\d{1,4})?|\\d{1,4}[ \\.\\/\\-]\\d{1,4}([ \\.\\/\\-]\\d{1,4})?)( \\d{1,2}:\\d{1,2}(:\\d{1,2})?)?$/iu', $dateValue)) {
    return FALSE;
  }
  $dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue);
  if ($dateValueNew === PHPExcel_Calculation_Functions::VALUE()) {
    return FALSE;
  }
  else {
    if (strpos($dateValue, ':') !== FALSE) {
      $timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($dateValue);
      if ($timeValue === PHPExcel_Calculation_Functions::VALUE()) {
        return FALSE;
      }
      $dateValueNew += $timeValue;
    }
    return $dateValueNew;
  }
}