How to Set Timezone in Laravel 5.1

Set Timezone in Laravel 5.1
We can set timezone in config file config/app.php at below section.
You have to set a timezone supported by PHP. An overview about available timezones can be find here: http://php.net/manual/en/timezones.php

/*
|————————————————————————–
| Application Timezone
|————————————————————————–
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
//  Default value of timezone is ‘UTC’,
‘timezone’ => ‘UTC’,

// I have changed it to ‘Asia/Kolkata’ because i need indian timezone.

‘timezone’  => ‘Asia/Kolkata’,

Show queries in laravel

 

Laravel provides a database query builder. To see the query use toSql() in laravel.

 

$result = DB::table(‘users’)
->where(‘username’, ‘like’, ‘%admin%’)
->toSql() // to see the query which is executed
//  ->get()->toArray();  to get results
dd($result)

Laravel update record

Use Query Builder to update records, This is a sample:

Or Use another method to load DB