i have a database where unfortunately the date information is stored as an integer, for example 20231231 for December 31, 2023.
Please don’t ask why this was done, but this is how the database was provided to me.
What is the best practice for converting this format to a more sensible one in CakePHP 4?
I started writing my own DateType, extending the BaseType and implementing my conversion in the toPHP() and toDatabase() methods.
However, now the date fields are not being displayed as “datetime-local” type in the form helper.
// In my bootstrap.php
TypeFactory::map(‘mydate’, ‘App\Database\Type\DateType’);
// In my Table
$schema->setColumnType($column, ‘mydate’);
okay, that is the right way… can i tell the form-helper that it use automatically that type or do I always have to specify the type here?
$this->Form->control(‘published’, [‘type’ => ‘datetime’]);