From 7479bacbd0cbd4c7e087b9cfc362465d406d92d5 Mon Sep 17 00:00:00 2001 From: "vladimir.panivko" Date: Wed, 17 Jan 2024 07:58:02 +0100 Subject: [PATCH] strftime add format --- Log.php | 6 ++++-- tests/formatTime.phpt | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Log.php b/Log.php index 1ff0974..c3a27e4 100755 --- a/Log.php +++ b/Log.php @@ -850,7 +850,8 @@ private function convertStrftimeFormatConverter(string $timeFormat): string '%G', '%Y', '%y', '%P', '%p', '%l', '%I', '%H', '%M', '%S', '%z', '%Z', - '%s' + '%s', + '%x', '%X', ]; // http://php.net/manual/en/function.date.php @@ -861,7 +862,8 @@ private function convertStrftimeFormatConverter(string $timeFormat): string 'o', 'Y', 'y', 'a', 'A', 'g', 'h', 'H', 'i', 's', 'O', 'T', - 'U' + 'U', + 'm/d/Y', 'H:i:s', ]; $pattern = array_map( diff --git a/tests/formatTime.phpt b/tests/formatTime.phpt index ec4d526..a122e9d 100644 --- a/tests/formatTime.phpt +++ b/tests/formatTime.phpt @@ -22,6 +22,7 @@ $tests = [ ['timeFormat' => '%P %p %l %I %H %M %S', 'timeFormatter' => null, 'expectedResult' => 'pm PM 8 08 20 17 28'], ['timeFormat' => '%z %Z', 'timeFormatter' => null, 'expectedResult' => '+0000 UTC'], ['timeFormat' => '%s', 'timeFormatter' => null, 'expectedResult' => '1704658648'], + ['timeFormat' => '%x %X', 'timeFormatter' => null, 'expectedResult' => '01/07/2024 20:17:28'], ['timeFormat' => 'Y-m-d H:i:s', 'timeFormatter' => function($timeFormat, $time) { return $time;}, 'expectedResult' => '1704658648'], ['timeFormat' => 'Y-m-d H:i:s', 'timeFormatter' => function($timeFormat, $time) { return $timeFormat;}, 'expectedResult' => 'Y-m-d H:i:s'], ]; @@ -55,5 +56,7 @@ Using strftime-style formatting is deprecated +0000 UTC OK Using strftime-style formatting is deprecated 1704658648 OK +Using strftime-style formatting is deprecated +01/07/2024 20:17:28 OK 1704658648 OK Y-m-d H:i:s OK