I have the following code in codeigniter 4:
$recordset=$this->db->select('turno_id, paciente,date_format(fecha, "%W %d-%M-%Y %H:%i") as fecha,observaciones,obra_social,usuario_id' , false)
->where('year(fecha)','year(now())', false)
->where('usuario_id',$usuario_id)
->get("turnos");
That returns the date to me in this way: Wednesday 22-June-2022 23:16
and through Datatables I dump it into a table. How do I get it to return to me in Spanish or translate it into Spanish?
Have you tried using
setlocale
? I used it in a pure PHP code without DB. It received the date from a field and initially it printed the same way it prints you. But withsetlocale
a slightly different syntax, I managed to get it to print in Spanish.I leave the code to see if it can help you or give you an idea:
Already solved. Since I am using codeigniter3 I created a model with the following code:
and then I loaded it in config->autoload like so
The following article gave me an idea.