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

LaraBABA's avatar

Date getters setter problem with calendar

Hi all,

I would like to have a bit of advice on this please.

I have 4 calendar widgets,, I need to show in the admin panel the date as: d-m-Y H:i:s

But, when I click on "Edit", this format does not work as it needs to be from mariabd as: Y-m-d H:i:s 2022-08-22 13:08:56

How would you deal with this please?

Thanks

Here are my setters in my model


    public function getFromDateAttribute($value)
    {
        return Carbon::parse($value)->format('d-m-Y H:i:s');
    }

    public function getToDateAttribute($value)
    {
        return Carbon::parse($value)->format('d-m-Y H:i:s');
    }

    public function getActiveFromAttribute($value)
    {
        return Carbon::parse($value)->format('d-m-Y H:i:s');
    }

    public function getActiveToAttribute($value)
    {
        return Carbon::parse($value)->format('d-m-Y H:i:s');
    }

My 4 calendars:


 <x-inputs.group class="w-full lg:w-6/12">
        <x-inputs.datetime
            name="active_from"
            label="Publishing ON"
            value="{{ old('active_from', ($editing ? optional($event->active_from)->format('Y-m-d\TH:i:s') : '')) }}"
            max="255"
            required
        ></x-inputs.datetime>
    </x-inputs.group>

    <x-inputs.group class="w-full lg:w-6/12">
        <x-inputs.datetime
            name="active_to"
            label="Publishing OFF"
            value="{{ old('active_to', ($editing ? optional($event->active_to)->format('Y-m-d\TH:i:s') : '')) }}"
            max="255"
            required
        ></x-inputs.datetime>
    </x-inputs.group>

    <x-inputs.group class="w-full lg:w-6/12">
        <x-inputs.datetime
            name="from_date"
            label="Booking ON"
            value="{{ old('from_date', ($editing ? optional($event->from_date)->format('Y-m-d\TH:i:s') : '')) }}"
            max="255"
            required
        ></x-inputs.datetime>
    </x-inputs.group>

    <x-inputs.group class="w-full lg:w-6/12">
        <x-inputs.datetime
            name="to_date"
            label="Booking OFF"
            value="{{ old('to_date', ($editing ? optional($event->to_date)->format('Y-m-d\TH:i:s') : '')) }}"
            max="255"
            required
        ></x-inputs.datetime>
    </x-inputs.group>

Any idea how to go around this issue in a simple way please?

Thank you

0 likes
0 replies

Please or to participate in this conversation.