What is the current format in that column?
Sep 23, 2021
6
Level 1
changing 'last_activity' format in query
Hi,
I'm trying to get the date of 'last_activty' column of the sessions table, in the correct date format like
year-month-day H:m:seconds
but i don't recognize the format of the 'time' in this column, so i don't know how to do it.
I'm trying to get it in a query by the way, so i will not use ' format->() '.
Thanks.
Level 104
It is a timestamp, so the FROM_UNIXTIME function in mysql can convert to a datetime for you:
DB::table('sessions')->selectRaw('*, FROM_UNIXTIME(last_activity) as last_activity_datetime')->get();
1 like
Please or to participate in this conversation.