0

I want to change date out put from following SELECT query to DD/MM/YYY format . pls advice.

this is what I tried so far

  ->select('time_sheets.progress',DATE_FORMAT('time_sheets.date', "%d/%l/%Y") ,'role_users.role_id','roles.role_name')

3 Answers 3

3

Instead of using ->select you can use selectRaw to allow raw SQL query so you can use:

->selectRaw('time_sheets.progress, DATE_FORMAT(time_sheets.date, "%d/%l/%Y"), role_users.role_id, roles.role_name');
Sign up to request clarification or add additional context in comments.

Comments

0
->select(DB::raw('DATE_FORMAT(FROM_UNIXTIME(column_name), "%Y-%m-%d %h:%i:%s") as cstime_value'))

1 Comment

Please edit your answer to include some explanation. Code-only answers do very little to educate future SO readers. Your answer is in the moderation queue for being low-quality.
0
->select('time_sheets.progress',\DB::raw('DATE_FORMAT(p.created_at,\'%d-%m-%Y\') as data')), role_users.role_id, roles.role_name');

Hope to help someone else !

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.