Save time value, missing seconds if 00

I post time 01:00:00 , after post form result is -> $this->request->getData()

'time_winner' => '01:00',

If post 01:00:01

result is ok

'time_winner' => '01:00:01',

Please advice on how to get the full time format? Because the patch entity then does not work.

Thank you

What does your form look like? Do you have some JavaScript or something on that? Because what I’m used to seeing with default code for time fields is an array with hour, minute and second separated.

Input is:

<input type="time" name="time_winner" required="required" id="time-winner" step="1" value="01:00:00">

No JavaScript, but input type text is return seconds… :roll_eyes: So it happens in chrome, firefox is ok

This issue will be fixed in Cakephp 4.2.
As a workaround you can reformat the time-data in a beforeMarshal-function in your model like this:

public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options)
        if ($data['departuretime']) {
            $data['departuretime'] = new FrozenTime($data['departuretime']);

Hope this helps.

1 Like