P粉0116843262023-08-31 09:37:41
$model->checkin_date_time
is not "2022-12-12 22:22:22"
It is a Carbon (subclass of DateTime) object. When you try to convert it to a string (using echo
, any kind of display, or inject it into another string, it will automatically be formatted as Y-m-d h:i:s
If you want to output in other formats, please use ->format()
method:
$check_in = $model->checkin_date_time->format('Y-m-d\Th:i:s');
Regardless, using offsets ($check_in[10] =
syntax) to modify letters in a string is really a bad idea, and this micro-optimization is not worth it.