Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

383
Visualizações
Can't Get Bootstrap DateTime Picker To Show Formatted database Value in Form Field

I am trying to use the Bootstap DateTime picker in a Laravel project.
https://www.malot.fr/bootstrap-datetimepicker/

I am working on an edit page where a date is pulled from the database and should display formatted as mm/dd/yyyy hh:ii in an input field. I need that DT picker to start off from the same DT. I cannot figure out how to do it without messing up the InitialDate for the timePicker. If I add a formatted value to the input value field, it sends the InitialDate of the DT picker back to Dec 1899.

Here is the Javascript portion of the code:

<script src="{{asset('/assets/plugins/bootstrap-datetime-picker/js/bootstrap-datetimepicker.js')}}"></script>
 $(".form_datetime").datetimepicker({
            format: "mm/dd/yyyy hh:ii",
            initialDate:  "{{ $post->post_date }}",
            autoclose: true,
            todayBtn: true,
            pickerPosition: "bottom-left",
            minuteStep: 10
        });

Here is the form field without the formatted DT.

<input class="form-control @error('post_date') is-invalid @enderror"  type="text" value="" readonly id="post_date" name="post_date">

Here is the form field with the formatted DT:

{{ $post->post_date->format('m/d/Y H:i:s') }}

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can try this

{{ \Carbon\Carbon::parse($post->post_date)->format('m/d/Y H:i:s') }}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda