@@ -36,8 +36,10 @@ public function handle(QueryExecuted $event): void
3636 ? $ event ->connection ->getPdo ()
3737 : null ;
3838
39+ $ dateFormat = $ event ->connection ->getQueryGrammar ()->getDateFormat ();
40+
3941 $ bindings = $ event ->connection ->prepareBindings ($ event ->bindings );
40- $ bindings = \array_map (fn ($ value ) => $ this ->prepareValue ($ pdo , $ value ), $ bindings );
42+ $ bindings = \array_map (fn ($ value ) => $ this ->prepareValue ($ pdo , $ dateFormat , $ value ), $ bindings );
4143
4244 $ query = $ this ->prepareQuery ($ event ->sql , $ bindings );
4345
@@ -63,7 +65,7 @@ protected function prepareQuery(string $query, array $bindings): string
6365 return $ query ;
6466 }
6567
66- protected function prepareValue (?\PDO $ pdo , $ value ): string
68+ protected function prepareValue (?\PDO $ pdo , string $ dateFormat , $ value ): string
6769 {
6870 if (\is_null ($ value )) {
6971 return 'NULL ' ;
@@ -81,18 +83,18 @@ protected function prepareValue(?\PDO $pdo, $value): string
8183 return $ this ->quote ($ pdo , '[BINARY DATA] ' );
8284 }
8385
84- if (\is_object ($ value ) && \method_exists ($ value , 'toString ' )) {
85- $ value = $ value ->toString ();
86- }
87-
8886 if ($ value instanceof \DateTimeInterface) {
89- $ value = $ value ->format (' Y-m-d H:i:s ' );
87+ $ value = $ value ->format ($ dateFormat );
9088 }
9189
9290 if ($ value instanceof \Stringable) {
9391 $ value = \strval ($ value );
9492 }
9593
94+ if (\is_object ($ value ) && \method_exists ($ value , 'toString ' )) {
95+ $ value = $ value ->toString ();
96+ }
97+
9698 // objects not implementing __toString() or toString() will fail here
9799 return $ this ->quote ($ pdo , \strval ($ value ));
98100 }
0 commit comments