在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):jamesmills/laravel-timezone开源软件地址(OpenSource Url):https://github.com/jamesmills/laravel-timezone开源编程语言(OpenSource Language):PHP 97.7%开源软件介绍(OpenSource Introduction):Laravel TimezoneAn easy way to set a timezone for a user in your application and then show date/times to them in their local timezone. How does it workThis package listens for the This package uses the torann/geoip package which looks up the users location based on their IP address. The package also returns information like the users currency and users timezone. You can configure this package separately if you require. How to useYou can show dates to your user in their timezone by using {{ Timezone::convertToLocal($post->created_at) }} Or use our nice blade directive @displayDate($post->created_at) InstallationPull in the package using Composer
Publish database migrations
Run the database migrations. This will add a
ExamplesShowing date/time to the user in their timezoneDefault will use the format {{ Timezone::convertToLocal($post->created_at) }}
// 4th July 2018 3:32:am If you wish you can set a custom format and also include a nice version of the timezone {{ Timezone::convertToLocal($post->created_at, 'Y-m-d g:i', true) }}
// 2018-07-04 3:32 New York, America Using blade directiveMaking your life easier one small step at a time @displayDate($post->created_at)
// 4th July 2018 3:32:am And with custom formatting @displayDate($post->created_at, 'Y-m-d g:i', true)
// 2018-07-04 3:32 New York, America Saving the users input to the database in UTCThis will take a date/time, set it to the users timezone then return it as UTC in a Carbon instance. $post = Post::create([
'publish_at' => Timezone::convertFromLocal($request->get('publish_at')),
'description' => $request->input('description'),
]); Custom ConfigurationPublishing the config file is optional. php artisan vendor:publish --provider="JamesMills\LaravelTimezone\LaravelTimezoneServiceProvider" --tag=config Flash MessagesWhen the timezone has been set, we display a flash message, By default, is configured to use Laravel default flash messaging, here are some of the optional integrations. laracasts/flash - mercuryseries/flashy - spatie/laravel-flash - mckenziearts/laravel-notify - usernotnull/tall-toasts - To override this configuration, you just need to change the Overwrite existing timezones in the databaseBy default, the timezone will be overwritten at each login with the current user timezone. This behavior can be restricted to only update the timezone if it is blank by setting the Default FormatBy default, the date format will be Lookup ArrayThis lookup array configuration makes it possible to find the remote address of the user in any attribute inside the Laravel User MessageYou may configure the message shown to the user when the timezone is set by changing the Underlying GeoIp PackageIf you wish to customise the underlying php artisan vendor:publish --provider="Torann\GeoIP\GeoIPServiceProvider" --tag=config ChangelogPlease see CHANGELOG for more information what has changed recently. ContributingPlease see CONTRIBUTING for details. LicenseThis package is 100% free and open-source, under the MIT license. Use it however you want. This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats. IssuesIf you receive a message like |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论