Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

adamjhn's avatar

Why in the date field appears "dd MM yyyy - hh:ii"?

I have the format in datetime picker like "format: "dd MM yyyy - hh:ii" and to store the date in the database is used the format " 'start_date' => Carbon::createFromFormat('d F Y - H:i', $request->start_date), ".

In the conference details page I want to show the stored date in db. But like below in the date field appears "dd MM yyyy - hh:ii" instead of appear the date. Do you know why?

    <div class="form-row">
        <div class="form-group col-md-6">
            <label for="start_date">Start date</label>
            <div class="input-group date" data-provide="datepicker">
                <input type='text' onkeydown="event.preventDefault()"
                       name="start_date" value="{{!empty($conference->start_date) ? $conference->start_date->formatLocalized('dd MM yyyy - hh:ii'): ''}}
                        "
                       class="form-control" placeholder="DD/MM/YYY" />
                <span class="input-group-addon"><i class="fa fa-calendar text-primary" aria-hidden="true"></i></span>
            </div>
        </div>
        <div class="form-group col-md-6">
            <label for="end_date">End date
            <div class="input-group date" data-provide="datepicker">
                <input type='text' class="form-control"
                       value=" {{!empty($conference->start_date) ? $conference->start_date->formatLocalized('dd MM yyyy - hh:ii'): ''}}
                               " name="end_date" placeholder="DD/MM/YYY"/>
                <span class="input-group-addon"><i class="fa fa-calendar text-primary" aria-hidden="true"></i></span>
            </div>
        </div>
    </div>
0 likes
3 replies
Cronix's avatar

But like below in the date field appears "dd MM yyyy - hh:ii" instead of appear the date. Do you know why?

Because that's what you're telling it to do?

$conference->start_date->formatLocalized('dd MM yyyy - hh:ii')
Cronix's avatar

You're also using the start_date value to populate the end_date field...

<input type='text' class="form-control" value=" {{!empty($conference->start_date) ? $conference->start_date->formatLocalized('dd MM yyyy - hh:ii'): ''}}" name="end_date" placeholder="DD/MM/YYY"/>

as well as an extra space in your value, which will mess it up.

jlrdw's avatar

Because that's what you're telling it to do?

A famous quotes section needs to be started.

Please or to participate in this conversation.