Skip to content

Commit cc6be2c

Browse files
Revert "fix ignoring date format"
This reverts commit 8dea0c0.
1 parent 8dea0c0 commit cc6be2c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Eloquent/DocumentModel.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function getQualifiedKeyName()
106106
*
107107
* @param mixed $value
108108
*/
109-
public function fromDateTime($value): UTCDateTime|string
109+
public function fromDateTime($value): UTCDateTime
110110
{
111111
// If the value is already a UTCDateTime instance, we don't need to parse it.
112112
if ($value instanceof UTCDateTime) {
@@ -117,9 +117,7 @@ public function fromDateTime($value): UTCDateTime|string
117117
if (! $value instanceof DateTimeInterface) {
118118
$value = parent::asDateTime($value);
119119
}
120-
if (isset($this->dateFormat)) {
121-
return $value->format($this->getDateFormat());
122-
}
120+
123121
return new UTCDateTime($value);
124122
}
125123

@@ -150,6 +148,9 @@ public function getDateFormat()
150148
/** @inheritdoc */
151149
public function freshTimestamp()
152150
{
151+
if (isset($this->dateFormat)) {
152+
return Date::now();
153+
}
153154
return new UTCDateTime(Date::now());
154155
}
155156

0 commit comments

Comments
 (0)