Skip to content

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.

License

Notifications You must be signed in to change notification settings

poldixd/human-readable-time

Repository files navigation

Show date time or human readable time 🕐 👀

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.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Languages