saifuldev / get-date-difference
A package to calculate date differences.
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.2
- laravel/framework: ^10.10
- laravel/sanctum: ^3.3
- laravel/tinker: ^2.8
Requires (Dev)
- fakerphp/faker: ^1.9.1
- laravel/pint: ^1.0
- laravel/sail: ^1.18
- mockery/mockery: ^1.4.4
- nunomaduro/collision: ^7.0
- phpunit/phpunit: ^10.1
- spatie/laravel-ignition: ^2.0
This package is auto-updated.
Last update: 2025-04-17 06:21:29 UTC
README
The getDateDifference function calculates the time difference between the current date and a specified date, returning the difference in a human-readable format. The output is dynamically adjusted to display the difference in seconds, minutes, hours, days, weeks, months, or years, depending on the magnitude of the difference.
-
Install the Package : composer require saifuldev/get-date-difference
-
Use the Package in Your Laravel Application Step 2.1: Import the class and use it in your Laravel code. Here’s an example of how you might call the calculateDifference method in a controller:
- Register the Service Provider (if applicable) If your package includes a service provider and you want to use it, register it in the config/app.php file under the providers array.
- Saifuldev\GetDateDifference\GetDateDifferenceServiceProvider::class,
use App\Http\Controllers\DateController;
Route::get('/date-difference', [DateController::class, 'showDifference']);