Illuminate query builder, how to convert dates to Carbon object
问题 Is there any chance to use Illuminate Query builder to get dates as Carbon objects instead of strings? For example: $user=DB::table('users')->select(["id","lastLogin"])->where("id",1)->first(); $user->lastLogin; // <--- Carbon instead of string! 回答1: You can use Carbon::parse($user->lastLogin) , but I think there is no native way to get dates as carbon objects without using eloquent. An example is this answer on stackoverflow. I think working with eloquent models will make the work much