2017 © Pedro Peláez
 

library time-label

Laravel package to manage time labels like `This Month` and so on.

image

sukohi/time-label

Laravel package to manage time labels like `This Month` and so on.

  • Saturday, October 17, 2015
  • by Sukohi
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

TimeLabel

Laravel package to manage time labels like This Month and so on., (*1)

Installation

Add this package name in composer.json, (*2)

"require": {
  "sukohi/time-label": "2.*"
}

Execute composer command., (*3)

composer update

Register the service provider in app.php, (*4)

'providers' => [
    ...Others...,  
    Sukohi\TimeLabel\TimeLabelServiceProvider::class,
]

Also alias, (*5)

'aliases' => [
    ...Others...,  
    'TimeLabel'   => Sukohi\TimeLabel\Facades\TimeLabel::class
]

Usage

$time_label = TimeLabel::setLabel([
    'today' => 'Today',
    'yesterday' => 'Yesterday',
    'this_month' => 'This Month',
    'last_month' => 'Last Month',
    'other' => 'M, Y'   // You need to set date format only here.
]);
$date_times = [
    Carbon::now(),
    Carbon::now(),
    Carbon::now()->subDay(),
    Carbon::now()->subDay(),
    Carbon::now()->subDays(2),
    Carbon::now()->subDays(4),
    Carbon::now()->subDays(4),
    Carbon::now()->subDays(5),
    Carbon::now()->subDays(10),
    Carbon::now()->subDays(20),
    Carbon::now()->subDays(50),
    Carbon::now()->subDays(150),
];

foreach($date_times as $dt) {

    if($time_label->isFirst($dt)) {

        echo $time_label->get($dt) .'<br>';

    }

    echo $dt .'<hr>';

}

License

This package is licensed under the MIT License., (*6)

Copyright 2015 Sukohi Kuhoh, (*7)

The Versions

17/10 2015

2.0.x-dev

2.0.9999999.9999999-dev

Laravel package to manage time labels like `This Month` and so on.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

17/10 2015

dev-master

9999999-dev

Laravel package to manage time labels like `This Month` and so on.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

17/10 2015

2.0.1

2.0.1.0

Laravel package to manage time labels like `This Month` and so on.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi

17/10 2015

2.0.0

2.0.0.0

Laravel package to manage time labels like `This Month` and so on.

  Sources   Download

MIT

The Requires

 

by Avatar Sukohi