2017 © Pedro Peláez
 

library simple-php-timer

An elegant timer solution for php

image

lucasruroken/simple-php-timer

An elegant timer solution for php

  • Saturday, December 31, 2016
  • by lucasruroken
  • Repository
  • 0 Watchers
  • 1 Stars
  • 1,114 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 12 % Grown

The README.md

Simple php timer

This is a simple solution for managing dates in php. There is no need to research how to print dates. All you need is right here!, (*1)

How to install?

Run in your terminal, (*2)

composer require lucasruroken/simple-php-timer

or just add into your composer.php, (*3)

"require": {
    "lucasruroken/simple-php-timer": "~1.0"
},

How to use?

First of all, you need to include the Timer class, (*4)

use LucasRuroken\SimplePhpTimer\Timer;

and then wherever you want to get a datetime, (*5)

echo (new Timer())->today();

This will print the current date. Note that the default format is Y-m-d H:i:s You can simple override this by passing a format function, (*6)

echo (new Timer())->today()->format('Y-d');

If you want, you can create a custom date like this, (*7)

echo (new Timer())->yearsAgo(2)->monthsAgo(2);

This prints 2 years and 2 months ago, (*8)

echo (new Timer())->years(3)->days(2);

This prints 3 years and 2 days from today, (*9)

If you don't like to type (new Timer())->function();, you are able to call a static function, (*10)

echo Timer::create()->yesterday();

List of methods

  • ->seconds() + seconds
  • ->secondsAgo() - seconds
  • ->minutes() + minutes
  • ->minutesAgo() - minutes
  • ->hours() + hours
  • ->hoursAgo() - hours
  • ->days() + days
  • ->daysAgo() - days
  • ->months() + months
  • ->monthsAgo() - months
  • ->years() + years
  • ->yearsAgo() - years
  • ->today() - return current date
  • ->yesterday() - return yesterday date
  • ->format() Override default format
  • ->get() return time

The Versions

31/12 2016

dev-master

9999999-dev

An elegant timer solution for php

  Sources   Download

The Requires

  • php >=5.6

 

The Development Requires

by Avatar lucasruroken

27/12 2016

v1.0.1

1.0.1.0

An elegant timer solution for php

  Sources   Download

The Requires

  • php >=5.6

 

The Development Requires

by Avatar lucasruroken

24/12 2016

v1.0

1.0.0.0

An elegant timer solution for php

  Sources   Download

The Requires

  • php >=5.6

 

The Development Requires

by Avatar lucasruroken