Skip to content

Helpers for converting time to seconds.

License

Notifications You must be signed in to change notification settings

adevade/seconds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

91b0cfc · Sep 4, 2024

History

55 Commits
Sep 4, 2024
May 25, 2023
Apr 16, 2021
Feb 28, 2020
Feb 8, 2020
Oct 25, 2021
May 25, 2023
Feb 6, 2020
Oct 3, 2022
Oct 3, 2022
Aug 16, 2021
Oct 3, 2022

Repository files navigation

Seconds

Tests Latest Version on Packagist Total Downloads

Helpers for converting time to seconds.

Installation

You can install the package via composer:

composer require adevade/seconds

Supported PHP versions

Package PHP
^1.0 ^7.2
^2.1 ^7.2|^8.0
^3.0 ^7.4|^8.0
^4.0 ^8.0

Usage

use Adevade\Seconds;

Seconds::fromMinutes(2); // returns => (int) 120

Available methods

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();

Available constants

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.

Credits

Idea came from a tweet by @LasseRafn. Thanks!