diff --git a/src/PhpSpreadsheet/Calculation/TextData/Format.php b/src/PhpSpreadsheet/Calculation/TextData/Format.php index 93e728202f..5e0762fd69 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Format.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Format.php @@ -129,7 +129,7 @@ public static function TEXTFORMAT($value, $format) $format = Helpers::extractString($format); if (!is_numeric($value) && Date::isDateTimeFormatCode($format)) { - $value = DateTimeExcel\DateValue::fromString($value); + $value = DateTimeExcel\DateValue::fromString($value) + DateTimeExcel\TimeValue::fromString($value); } return (string) NumberFormat::toFormattedString($value, $format); diff --git a/tests/data/Calculation/TextData/TEXT.php b/tests/data/Calculation/TextData/TEXT.php index 1c7c338adb..5bf87a87df 100644 --- a/tests/data/Calculation/TextData/TEXT.php +++ b/tests/data/Calculation/TextData/TEXT.php @@ -61,6 +61,16 @@ '1-Jan-2012', 'yyyy-mm-dd', ], + 'time (issue 3409)' => [ + '09:01:00', + '09:01', + 'HH:MM:SS', + ], + 'datetime' => [ + '15-Feb-2014 04:17:00 PM', + '2014-02-15 16:17', + 'dd-mmm-yyyy HH:MM:SS AM/PM', + ], [ '1 3/4', 1.75,