I've recently discovered that my website produces error in Internet Explorer 11 and Microsoft Edge. Works well on all other browsers.
Error occures, when im using Carbon to create a date in Laravel.
Code:
$date = new Carbon(request('date'));
request('date') is like "YYYY-mm-dd", and its working perfectly in other browsers.
Error I get on this line is:
DateTime::__construct(): Failed to parse time string (2018-06-13) at position 0 (�): Unexpected character
I've tried a lot of other methods, to create the Carbon instance, all working fine in other borsers, but not in these.
Any idea, what could couse the problem?
EDIT: The data sent by the javascript is a string in this case "2018-06-13". I've tried to explode the string, and reconnect again, and convert some other ways. It says string(10) "2018-06-13" in most of the browsers, and string(19) "2018-06-13" in internet explorer, which is really wierd.
EDIT2: Script for creating the days for the calendar (Vue2.js):
weeks: function () {
var dayCount = this.calendar.days(this.displayedYear, this.displayedMonth),
dayIndex = this.calendar.day(this.displayedYear, this.displayedMonth, 0).getDay(),
weekCount = Math.ceil((dayCount + dayIndex) / 7);
var weeks = [];
for (var i = 0; i < weekCount; i++) {
var week = [];
for (var j = 0; j < 7; j++) {
var date = new Date(
this.displayedYear,
this.displayedMonth - 1,
i * 7 + j - dayIndex + 1
);
week.push(
date.getMonth() === this.displayedMonth - 1
? date : null
);
}
weeks[i] = week;
}
return weeks;
Blade for displaying:
<tr v-for="week in weeks()">
<td
v-for="day in week"
@click="setSelectionPivot(day)"
:class="classes(day)">
<span>
@{{ (day == null) ? '' : day.getDate() }}
</span>
</td>
</tr>
Function part to process:
this.selection = day;
Then I pass this with ajax to the code the error occures. Ask if anything else is needed. The thing I don't understand is how it works perfectly in any other browser?