Great conceptual question.
Ideally, this should be done in a view. In my applications, I use JavaScript to create an interface. The user interacts with the interface, and the interface maps these interactions to Ajax requests. The server returns timestamps (instead of formatted dates), and the interface maps these timestamps to formatted time strings. The model only “understands” timestamps and is apathetic to how people understand time. The controller does not understand anything.
However, CodeIgniter does not work this way. Instead, the controller requests information from the model, uses the view to visualize this information, and returns the view to the client. A view is just a template for providing information. It cannot translate information into another form in the same way as JavaScript can be.
An important principle: the controller must be apathetic for business logic. The value of time is part of the business logic. Therefore, the controller should not "understand" what the "timestamp" means, which is necessary for the controller to translate the timestamp into a user-readable string. This leaves a view and model.
As indicated, the view does not “understand” the information; he only places HTML tags around it.
All that remains is a model. When a client requests a resource, it must tell the server its locale. The controller must pass the locale of the model, and the model must "understand" the locale and format the time string accordingly.
source share