I need to convert a date that comes as a string to date, it is already formatted from mysql to '% d-% m-% Y', but it is in the view with jquery and recognizes it as a string.
I receive data converted to '% d-% m-% Y' in php codeigneiter:
$this->db->select("DATE_FORMAT(auto.fecha_reserva, '%d-%m-%Y') as fecha", FALSE);
$this->db->from('auto');
$datos=$this->db->get();
return $datos->result();
I get the data:
$.each(obj.resultado, function (ind, elem) {
ejemplo : alert(typeof("30-10-2017")); //viene desde la query
alert(typeof(elem.fecha));//retorna un String "dd-mm-yyyy
//necesito que elem.fecha sea un date en dd-mm-yyyy
//lo ideal seria formatearla sin uso de plugins
});