How to handle datetime between php (Laravel api) and javascript (AngularJS)

前端 未结 2 1588
一生所求
一生所求 2021-02-01 06:52

I\'m utterly stuck trying to make php api exchange dates with angular frontend.

From PHP to JS I seem to have it sorted. Since Laravel handles dates through Carbon I jus

2条回答
  •  遇见更好的自我
    2021-02-01 07:01

    $dt = Carbon::now();
    echo $dt->toW3cString();       // 2015-02-05T14:50:55+01:00
    

    since carbon can print it it can also parse this format

    Carbon::parse('2015-02-05T14:50:55+01:00');
    

    in javascript with moment.js momentjs.com

    moment().format(); // 2015-02-05T14:50:55+01:00
    

提交回复
热议问题