Helpers for converting time to seconds.
You can install the package via composer:
composer require adevade/seconds
Package | PHP |
---|---|
^1.0 | ^7.2 |
^2.1 | ^7.2|^8.0 |
^3.0 | ^7.4|^8.0 |
^4.0 | ^8.0 |
use Adevade\Seconds;
Seconds::fromMinutes(2); // returns => (int) 120
Seconds::fromMinutes($minutes = 5);
Seconds::fromHours($hours = 12);
Seconds::fromDays($days = 4);
Seconds::fromWeeks($weeks = 2);
Seconds::fromMonths($months = 6);
Seconds::fromYears($years = 2);
Seconds::fromMinute();
Seconds::fromHour();
Seconds::fromDay();
Seconds::fromWeek();
Seconds::fromMonth();
Seconds::fromYear();
Seconds::MINUTE;
Seconds::HOUR;
Seconds::DAY;
Seconds::WEEK;
Seconds::MONTH;
Seconds::YEAR;
Months have an average length of 30.42 days.
Years have an average length of 365.24 days.
Idea came from a tweet by @LasseRafn. Thanks!