Handle date correctly

0

I have a calendar where I'm using the Fullcalendar (javascript) library and when I click on an event I want more information to be displayed until all is right I now have a form field in a modal returned a date from the database but it returns as I'll show below:

Database:

Asthedateisarrivinginmydesiredfield:

Mycodesofar:

eventClick:function(event,jsEvent,view){$('#id').val(event.id);$('#ccod').val(event.codigoCliente);$('#mtitulo').val(event.title);$('#autor').val(event.autor);$('#inicioEdit').val(event.start);$('#importanciaEdit').val(event.impor);$('#descricaoEventoEdit').val(event.text);$('#modalEvento').modal();},

Modal:

<divclass="row"> 
        <div class="col-md-6">
              <label for="inicio">Data</label>
            </div>
            <div class="col-md-6">
              <label for="importancia">Prioridade</label>
            </div>
          <div class="form-group col-md-6">
            <div class="input-group date">
              <input type="text" class="form-control date" id="inicioEdit" name="data" />
              <div class="input-group-addon">
                <span class="glyphicon glyphicon-th"></span>
              </div>
            </div>
          </div>

I would like help getting this date returned in 'yyyy-mm-dd' format

    
asked by anonymous 03.07.2017 / 22:48

1 answer

0

You can treat the date as follows:

function dataAtualFormatada(){
var data = new Date();
var dia = data.getDate();
if (dia.toString().length == 1)
  dia = "0"+dia;
  var mes = data.getMonth()+1;
 if (mes.toString().length == 1)
  mes = "0"+mes;
  var ano = data.getFullYear();  
 return dia+"/"+mes+"/"+ano;
}
    
04.07.2017 / 22:12