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

hcastillo's avatar

Convert Momentjs to Carbon

Hi, i using datetimepicker from jquery with this config (down) to get a date

    $(function () {
        $('.id_1').datetimepicker({
            "allowInputToggle": true,
            "showClose": true,
            "showClear": true,
            "showTodayButton": true,
            "format": "dddd, MMMM Do YYYY, h:mm:ss a",
        });

and getting (The format i want it) this Wednesday, August 31st 2022, 3:42:35 pm i want to convert that to carbon date

$format = 'dddd/mmmm/YYYY H:i:s a';
Carbon::createFromFormat($format,$data['start_mission_datetime']) ;

but the format in not right.. and i can find anything

any ideas?

0 likes
3 replies
tykus's avatar
tykus
Best Answer
Level 104

This moment format dddd, MMMM Do YYYY, h:mm:ss a would be represented as 'l, F jS Y, H:i:s a' in PHP. But, this is not the same as the dddd/mmmm/YYYY H:i:s a format in your PHP, so what does the data received actually look like?

hcastillo's avatar

@tykus Thank you, that make the work. Extra cuestion, in case the momentjs date locate es another that english, should change something from carbon, right?

Please or to participate in this conversation.