How to display the time in 24 hour format using datetimepicker?

Asked

Viewed 891 times

1

I’m trying to display in PM format, but whenever I select in timepicker it arrow as AM.

$('.datetimepicker').datetimepicker({
    lang: 'pt-BR',
    timepicker: true,
    format: 'd/m/Y h:i'
});

inserir a descrição da imagem aqui

When I select the time, example 21:00 it arrow as 09:00:

inserir a descrição da imagem aqui

1 answer

3


Simple, you are reporting in time format h in minuscule, so that it works in mode 24 hours you must inform him in capital letters H.

jQuery.datetimepicker.setLocale('pt-BR');
$('#datetimepicker').datetimepicker({
    timepicker: true,
    format: 'd/m/Y H:i'
});
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/jquery.datetimepicker.min.css">
<input id="datetimepicker" type="text" >
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/build/jquery.datetimepicker.full.js"></script>

You can see in the documentation this one among other examples.

  • Gee, I can’t believe it was that old, my God in heaven kkkk, thank you so much you saved my day haha!

  • It happens to anyone :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.