From 491bf18b5874caab94e4f9c68a95067409b5b131 Mon Sep 17 00:00:00 2001 From: elbaz michael Date: Wed, 22 Jul 2015 18:43:54 +0200 Subject: [PATCH 1/2] date regex 1 - at line 216 you regex is completly wrong (so is completly randoming result) 2 - You should never never change the user data in line 222 you do so weird things and i found myslef have a date like this -- expected ==> 12/06/2015 -- after youre class modification 06/12/2015 so remove the 222 line or fix your code. thanks. --- php-export-data.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/php-export-data.class.php b/php-export-data.class.php index d983cf7..c121fe4 100755 --- a/php-export-data.class.php +++ b/php-export-data.class.php @@ -218,6 +218,7 @@ private function generateCell($item) { ($timestamp > 0) && ($timestamp < strtotime('+500 years'))) { $type = 'DateTime'; + $item = strftime("%Y-%m-%dT%H:%M:%S",$timestamp); $style = 'sDT'; // defined in header; tells excel to format date for display } @@ -239,4 +240,4 @@ function sendHttpHeaders() { header("Content-Disposition: inline; filename=\"" . basename($this->filename) . "\""); } -} \ No newline at end of file +} From 2223766c01cdf74c8fc5513e45b4d6c64073d57e Mon Sep 17 00:00:00 2001 From: elbaz michael Date: Wed, 22 Jul 2015 19:03:04 +0200 Subject: [PATCH 2/2] update generateCell fix the regex and for now removing the date format --- php-export-data.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php-export-data.class.php b/php-export-data.class.php index c121fe4..69dda81 100755 --- a/php-export-data.class.php +++ b/php-export-data.class.php @@ -213,13 +213,13 @@ private function generateCell($item) { // Note we want to be very strict in what we consider a date. There is the possibility // of really screwing up the data if we try to reformat a string that was not actually // intended to represent a date. - elseif(preg_match("/^(\d{1,2}|\d{4})[\/\-]\d{1,2}[\/\-](\d{1,2}|\d{4})([^\d].+)?$/",$item) && + elseif(preg_match("/^(\d{1,2}|\d{4})[\/\-]\d{1,2}[\/\-](\d{4}|\d{1,2})([^\d].+)?$/",$item) && ($timestamp = strtotime($item)) && ($timestamp > 0) && ($timestamp < strtotime('+500 years'))) { $type = 'DateTime'; - $item = strftime("%Y-%m-%dT%H:%M:%S",$timestamp); + //$item = strftime("%Y-%m-%dT%H:%M:%S",$timestamp); $style = 'sDT'; // defined in header; tells excel to format date for display } else {