I'm utterly stuck trying to make php api exchange dates with angular frontend.
从PHP到JS,我似乎已经对它进行了排序.由于拉维尔通过Carbon 处理日期,我刚刚在应用程序中添加了\Carbon\Carbon::setToStringFormat('c');
个.php使日期在ISO8601中显示出来.
PHP example:
2015-02-04:00:53:51+02:00
天使JS日期过滤似乎也很好地理解了这种格式,甚至正确地读取了时区.
What I have yet to get working is posting JS date objects back to PHP api.
JS示例:
2015-02-05T13:00:00.000Z
Javascript date format ends up with milliseconds added to the string and in default configuration Carbon complains about trailing data.
此外,浏览器似乎会自动将我的日期转换为UTC时间.
起初,手动使用new Carbon('jsDateString')
似乎有效,但在更近距离的判断中,不考虑时区数据.
所以我的问题是,从AngularJS前端将日期发送回Laravel php api的最佳和最自动的解决方案是什么?