I'm having problems formatting the date.
As a matter of version, I can not define a date type field, so I must define it type datetime
and add several 0 to the end.
I get a json this:
Object {fecha_desde: "2017-01-01 00:00:00.000", fecha_hasta: "2017-04-30 00:00:00.000"}
And my intent is this:
<script>
$(document).ready(function(){
$('#cuatrimestre').on('change',function(){
var cuatrimestre = $(this).val();
$.ajax({
url : "getCuatri.php",
dataType: 'json',
type: 'POST',
async : false,
data : { cuatrimestre : cuatrimestre},
success : function(data) {
console.log(data)
//userData = JSON.parse(data);
var desde = String(data.fecha_desde).split('-');
var fechaDesde = desde[1] + '-' + desde[2] + '-' + desde[0];
$('#desde').val(fechaDesde);
var hasta = String(data.fecha_hasta).split('-');
var fechaHasta = hasta[1] + '-' + hasta[2] + '-' + hasta[0];
$('#hasta').val(fechaHasta);
//$('#hasta').val(data.fecha_hasta);
}
});
});
});
</script>
But I get this:
01-01 00:00:00.000-2017
04-30 00:00:00.000-2017
In the test mode I have the date type field, it works perfectly for me.