This is my current function to get all users:
function get_all() {
return $this->db->get($this->tableName)->result();
}
Now I have a function that changes the mysql DATETIME to ‘time ago’
timespan(human_to_unix($datetime),time());
How can I change all the mysql datetimes in the array that get_all produces before passing it to the controller and the view?
Secondly,
Is it correct to do this in the Model or should this be done in the Controller?
I would say the model is fine for doing this.
You have a number of options simply iterate over the array
e.g.
return $results;
if 5.3 php
Use something like array_walk with anonymous function