php - Get date from timestamp in laravel -


how can date "2015-07-31 06:03:21" using laravel query builder? in normal query using date() can date easily, don't know how use date() in laravel query builder. please check code sample given below , correct me?

normal query

select date('2015-07-31 06:03:21'), customer_id customer_histories 

laravel query builder

$customerhistory = customerhistory::where('customer_id', 1)             ->select('freetext', 'date(created_at)')             ->get(); 

you can db::raw(), though if selecting it, why not take created_at complete? default, eloquent convert created_at , updated_at columns instances of carbon can handle in code:

$customerhistory = customerhistory::where('customer_id', 1)             ->select('freetext', 'created_at')             ->get();  dd($customerhistory[0]->created_at->todatestring()); 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -