This is a Laravel port of the local_time gem from Basecamp. It makes it easy to display date and time to users in their local time. Its Blade components render a time HTML tag in UTC (making it cache friendly), and the JavaScript component immediately converts those elements from UTC to the Browser's local time.
Installation
Install the package via Composer:
composer require tonysm/local-time-laravel
Install the local-time JS lib via NPM:
npm install local-time -D
And then import it on your resources/app.js file, like so:
This package adds a couple Blade components to your project, they are:
">
<x-local-time:value="now()" />
Formats the Carbon instance using the default format string. It will convert the regular PHP formats to the strftime format for you.
">
<x-local-time:value="now()"format="F j, Y g:ia" />
Alias for with a month-formatted default. It converts that format to %B %e, %Y %l:%M%P.
">
<x-local-date:value="now()"format="F j, Y" />
You can configure the format used by passing it as a prop to the component. Any other attribute will be rendered in the generated time tag.
">
<x-local-time:value="now()"class="my-time" />
Renders the time tag using the default time format and adds the given class tag attribute to the element.
Note: The included strftime JavaScript implementation is not 100% complete. It supports the following directives: %a %A %b %B %c %d %e %H %I %l %m %M %p %P %S %w %y %Y %Z
Time ago helper
">
<x-local-time-ago:value="now()" />
Displays the relative amount of time passed. With age, the descriptions transition from {quantity of seconds, minutes, or hours} to {date + time} to {date}. The elements are updated every 60 seconds.
Examples (in quotes):
Recent: "a second ago", "32 seconds ago", "an hour ago", "14 hours ago"
Yesterday: "yesterday at 5:22pm"
This week: "Tuesday at 12:48am"
This year: "on Nov 17"
Last year: "on Jan 31, 2012"
Relative time helper
Preset time and date formats that vary with age. The available types are date, time-ago, time-or-date, and weekday. Like the component, type can be passed a string.
To configure the default date and time formats, you can use the useTimeFormat and useDateFormat methods on the LocalTimeLaravelFacade on your AppServiceProvider, like so:
The JavaScript lib allows some configurations as well as internationalization (i18n). To know more about that, head out to the Rails gem documentation.
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
A light weight laravel package that facilitates dealing with arabic concepts using a set of classes and methods to make laravel speaks arabic! concepts like , Hijri Dates & Arabic strings and so on ..
Laravel Jetstream is a beautifully designed application scaffolding for Laravel. Jetstream provides the perfect starting point for your next Laravel application and includes login, registration, email verification, two-factor authentication, session management, API support via Laravel Sanctum, and optional team management.
Asset Component is a port of Laravel 3 Asset for Orchestra Platform. The component main functionality is to allow asset declaration to be handle dynamically and asset dependencies can be resolve directly from the container. It however is not intended to becoma an asset pipeline package for Laravel, for such purpose we would recommend to use Grunt or Gulp.
Magewire is a Laravel Livewire port for Magento 2. The goal is to make it fun and easy to build modern, reactive and dynamic interfaces, without leaving the comfort of Magento's core layout and template systems. Magewire can be the missing piece when you intend to build dynamic and reactive features, but don't require or feel comfortable working with a full JavaScript framework like Vue or React.