We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5d1ad1e commit 5bb2651Copy full SHA for 5bb2651
system/DataCaster/Cast/DatetimeCast.php
@@ -62,6 +62,19 @@ public static function set(
62
self::invalidTypeValueError($value);
63
}
64
65
- return (string) $value;
+ if (! $helper instanceof BaseConnection) {
66
+ $message = 'The parameter $helper must be BaseConnection.';
67
+
68
+ throw new InvalidArgumentException($message);
69
+ }
70
71
+ $format = match ($params[0] ?? '') {
72
+ '' => $helper->dateFormat['datetime'],
73
+ 'ms' => $helper->dateFormat['datetime-ms'],
74
+ 'us' => $helper->dateFormat['datetime-us'],
75
+ default => throw new InvalidArgumentException('Invalid parameter: ' . $params[0]),
76
+ };
77
78
+ return $value->format($format);
79
80
0 commit comments