Skip to content

Commit fb4004d

Browse files
authored
Merge pull request #17117 from craftcms/bugfix/17114-time-field-serialization-v2
add serializeValueForDb method to the time field
2 parents 6a6f4a8 + 0891794 commit fb4004d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes for Craft CMS 4
22

3+
## Unreleased
4+
5+
- Fixed a bug where Time field values weren’t saving properly. ([#17114](https://github.com/craftcms/cms/issues/17114))
6+
37
## 4.15.0.1 - 2025-04-16
48

59
- Fixed an error that could occur when running “Updating search indexes” jobs.

src/fields/Time.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,15 @@ public function serializeValue(mixed $value, ?ElementInterface $element = null):
212212
return $value?->format('H:i:s');
213213
}
214214

215+
/**
216+
* @inheritdoc
217+
*/
218+
public function serializeValueForDb(mixed $value, ?ElementInterface $element): mixed
219+
{
220+
// Bypass Db::prepareDateForDb()
221+
return $this->serializeValue($value, $element);
222+
}
223+
215224
/**
216225
* @inheritdoc
217226
*/

0 commit comments

Comments
 (0)