File tree Expand file tree Collapse file tree 1 file changed +8
-14
lines changed
app/code/Magento/Sales/Plugin/Model/ResourceModel/Order Expand file tree Collapse file tree 1 file changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -49,12 +49,8 @@ public function aroundAddFieldToFilter(
49
49
if ($ field === 'created_at ' || $ field === 'order_created_at ' ) {
50
50
if (is_array ($ condition )) {
51
51
foreach ($ condition as $ key => $ value ) {
52
- if ($ value instanceof DateTimeInterface
53
- && $ value ->getTimezone ()->getName () !== $ this ->timeZone ->getConfigTimezone ()) {
54
- $ value ->setTimezone (new \DateTimeZone ($ this ->timeZone ->getConfigTimezone ()));
55
- }
56
- if ($ this ->isValidDate ($ value )) {
57
- $ condition [$ key ] = $ this ->timeZone ->convertConfigTimeToUtc ($ value );
52
+ if ($ value = $ this ->isValidDate ($ value )) {
53
+ $ condition [$ key ] = $ value ->setTimezone (new \DateTimeZone ('UTC ' ))->format ('Y-m-d H:i:s ' );
58
54
}
59
55
}
60
56
}
@@ -72,19 +68,17 @@ public function aroundAddFieldToFilter(
72
68
/**
73
69
* Validate date string
74
70
*
75
- * @param string| DateTimeInterface $datetime
76
- * @return bool
71
+ * @param DateTimeInterface|string $datetime
72
+ * @return mixed
77
73
*/
78
- private function isValidDate ($ datetime ): bool
74
+ private function isValidDate ($ datetime ): mixed
79
75
{
80
76
try {
81
- $ dt = is_string ($ datetime ) ? new DateTime ($ datetime ) : $ datetime ;
82
- if ($ dt instanceof DateTimeInterface) {
83
- return true ;
84
- }
77
+ return $ datetime instanceof DateTimeInterface
78
+ ? $ datetime : (is_string ($ datetime ) ? new DateTime ($ datetime ) : false );
79
+
85
80
} catch (\Exception $ e ) {
86
81
return false ;
87
82
}
88
- return false ;
89
83
}
90
84
}
You can’t perform that action at this time.
0 commit comments