poldixd/human-readable-time

1.1.0 2023-01-27 09:30 UTC

This package is auto-updated.

Last update: 2024-10-27 13:40:37 UTC


README

This package shows date time or human readable time. You can adjust the exact time when the package shows the date time instead the human readable time.

Human readable time example:

$datetime = \Carbon\Carbon::parse('2021-05-05 10:30:00')->subMinutes(15);

<x:human-readable-time :datetime="$datetime" />

Output:

<!-- Output -->
<time datetime="2021-05-05 10:15:00">15 minutes before</time>

Date time example:

$datetime = \Carbon\Carbon::parse('2021-05-05 10:30:00')->subMinutes(90);

<x:human-readable-time :datetime="$datetime" />

Output:

<!-- Output -->
<time datetime="2021-05-05 09:00:00">2021-05-05 09:00:00</time>

You can adjust the time when the date time is displayed. The default time is 1 hour.

$datetime = \Carbon\Carbon::parse('2021-05-05 10:30:00')->subMinutes(120);

<x:human-readable-time :datetime="$datetime" human-until="-3 hours" />

Output:

<!-- Output -->
<time datetime="2021-05-05 09:00:00">2 hour before</time>

Requirements

  • Laravel 9.x or Laravel 10.x
  • PHP 8.x

Installation

You can install the package via composer:

composer require poldixd/human-readable-time

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.