Hello so right now I have this data that i retrieved from the database table and the format is [“2021-08-17 23:13:15”] and i wish to change it into something like this 1629243333 (another data) because i want to get the difference in days between both time. I tried using the gettimeStamp() but it doesnt work.
$updateRaw = DB::table('tickets') ->where('id', $ticket) ->pluck('updated_at');
the $updateRaw is the data with the date format. Any help would be appreciated thanks
Advertisement
Answer
With Carbon do like this, if update_at
column is not carbon instance;
use CarbonCarbon; Carbon::parse($updateRaw[0])->timestamp;
if it is then simply do
$updateRaw[0]->timestamp;
for more : https://carbon.nesbot.com/