Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

376
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!