How to display time greater than 24H



Cakephp 3

In the database, I have a TIME field “run” , the content of this field can be greater than 24:00:00, for example 54:22:11

How can I display this time ?
Cake always display the date of the day
Note thats it is ok for time value below 23:59:59



A field that has the type TIME usually anticipates a time of day, for which values above 23:59:59 are invalid.

What you appear to have is an elapsed time, which may better be recorded as an INT for the number of seconds.


ah, reading the question properly, and you’re asking about the display of the value.

Most likely, the built in helpers will not assist, because they are expecting a time of day, rather than an elapsed time.

You’ll probably need to write your own function to convert seconds to an elapsed hours : minutes : seconds format.


ok thanks, for your reply
I will have to write code, nothing magic with cake for my problem :worried:

Do i have a way to make a request withtime_to_sec (the mysql command) ?


You can define a custom accessor in your Entity such that every time you retrieve a row, it will automatically apply your changes to the data. (same with a mutator for saving your data)

Here is a link to the appropriate docs for CakePHP 3:


I’m looking for a similar solution. But the mutator is not doing what I expected. What’s wrong?