I recommend you create a file/class which serves to house application CONST values, and then require that file/autoload that class in your application bootstrap file.
define("MYSQL_DATETIME_FORMAT", "Y-m-d H:i:s");
Then, define a property in your ApplicationController, such as $mysql_datetime = MYSQL_DATETIME_FORMAT;
, and pass this value into your views, a view helper, or a decorator class.
You can also create a user defined or class defined callback (i.e., a helper) which uses this value and performs conversions for you (such as function to_mysql_datetime($timeval){...}
. Then in your views, you could call:
$formatted_datetime = DateFormatHelper::to_mysql_datetime($other_datetime_value);
This is from the CakePHP documentation regarding this issue:
If you have any additional configuration needs, you should add them to
your application’s config/bootstrap.php file. This file is included
before each request, and CLI command.
This file is ideal for a number of common bootstrapping tasks:
Defining convenience functions.
Declaring constants.
Creating cache configurations.
Configuring inflections.
Loading configuration files.
Be careful to maintain the MVC software design pattern when you add
things to the bootstrap file: it might be tempting to place formatting
functions there in order to use them in your controllers. As you’ll
see in the Controllers and Views sections there are better ways you
add custom logic to your application.
Source