0
I have this button to start the task:
$('#IniciarTarefa').on('click', function () {
$(this).closest('.form-group').data('inicio', new Date().getTime());
});
$('#mostrar').on('click', function () {
var time = $('.form-group').data('inicio');
alert(new Date(time));
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="form-group">
<label class="col-md-4 control-label" for="IniciarTarefa" id="acao"></label>
<div class="col-md-4">
<button id="IniciarTarefa" name="IniciarTarefa" class="btn btn-info">Iniciar Tarefa</button>
</div>
</div>
<button id="mostrar">Mostrar quando tarefa foi iniciada</button>
But it shows the date this way:
And this way I can not enter in the database. I wanted to show only the date in this way:
2019-03-22 17:14:45
Possible duplicate of How to format date in javascript?
– Luiz Felipe