1. Go to this page and download the library: Download medicplus/laravel-timezone library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
medicplus / laravel-timezone example snippets
{{ Timezone::convertToLocal($post->created_at) }}
@displayDate($post->created_at)
{{ Timezone::convertToLocal($post->created_at) }}
// 4th July 2018 3:32:am
{{ Timezone::convertToLocal($post->created_at, 'Y-m-d g:i', true) }}
// 2018-07-04 3:32 New York, America
@displayDate($post->created_at)
// 4th July 2018 3:32:am
@displayDate($post->created_at, 'Y-m-d g:i', true)
// 2018-07-04 3:32 New York, America
namespace App;
use Illuminate\Database\Eloquent\Model;
use MedicPlus\LaravelTimezone\Casts\Timezone;
class Foo extends Model
{
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'created_at' => Timezone::class,
];
}