Package Data | |
---|---|
Maintainer Username: | raphaelbronsveld |
Maintainer Contact: | raphaelbronsveld@outlook.com (Raphaël Bronsveld) |
Package Create Date: | 2017-03-22 |
Package Last Update: | 2017-07-09 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-16 15:00:11 |
Package Statistics | |
---|---|
Total Downloads: | 93 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Laravel package providing easy Timezone functionality.
Made for people who really just want to have an easy way of going about dealing with timezones.
"raphaelb/timezones": "~1.4"
Raphaelb\Timezones\TimezonesServiceProvider::class,
'Timezones' => Raphaelb\Timezones\Facades\Timezones::class
use Raphaelb\Timezones\Facades\Timezones;
class User {
// Accessors in model class.
/**
* Get created_at attr.
* @param $date
* @return string
*/
public function getCreatedAtAttribute($date)
{
return app('timezones')
->toTimezone($date, 'gmt')
->format('d-m-Y H:i:s');
}
/**
* Get updated_at attr.
*
* @param $date
* @return string
*/
public function getUpdatedAtAttribute($date)
{
return app('timezones')
->toTimezone($date, 'gmt')
->format('d-m-Y H:i:s');
}
/**
* Or inject a format when you know the given one.
* Otherwise Carbon will fail.
*/
public function time()
{
// Constructor accepts a different format for your needs.
$time = new Timezones('m-d-Y H:i:s');
return $time->toTimezone('09-03-2016 16:00:00', 'EST');
}
}