diff --git a/src/Casts/DateTimeInterfaceCast.php b/src/Casts/DateTimeInterfaceCast.php index 4003d01e..71936855 100644 --- a/src/Casts/DateTimeInterfaceCast.php +++ b/src/Casts/DateTimeInterfaceCast.php @@ -14,7 +14,8 @@ public function __construct( protected null|string|array $format = null, protected ?string $type = null, protected ?string $setTimeZone = null, - protected ?string $timeZone = null + protected ?string $timeZone = null, + protected ?bool $setMidnight = false ) { } @@ -54,7 +55,12 @@ protected function castValue( $this->setTimeZone ??= config('data.date_timezone'); if ($this->setTimeZone) { - return $datetime->setTimezone(new DateTimeZone($this->setTimeZone)); + $datetime = $datetime->setTimezone(new DateTimeZone($this->setTimeZone)); + } + + //Force the time to 00:00:00.000 + if ($this->setMidnight) { + $datetime = $datetime->setTime(0, 0); } return $datetime;