A series of constants designed to make it easier to express time in PHP applications
MIT License
defined()
checks and unnecessary multiplication in order to a) help IDEs and b) remove an (albeit tiny) level of overhead (#21)Published by stevegrunwell 2 months ago
⚠️ Please note: this is a major release, as it contains a breaking change to how the constants are defined. An extra file has been included to help bridge the gap between versions if you wish to run version 2.x of this library without updating all references across your app(s).
TimeConstants
namespace (#18)This release moves the constants defined by this package from the global namespace into the TimeConstants
namespace.
Your implementations of these constants can be updated in either of the following ways:
use const TimeConstants\HOUR_IN_SECONDS;
- cache($key, $value, HOUR_IN_SECONDS);
+ cache($key, $value, \TimeConstants\HOUR_IN_SECONDS);
Alternatively, you may include the new GlobalAliases.php
file as a short-term fix. This file will take the newly-namespaced constants and also define them in the global namespace.
Either of the following approaches will ensure the aliased versions are loaded:
composer.json
file in the autoload.files
array:
"autoload": {
"files": [
"vendor/stevegrunwell/time-constants/src/GlobalAliases.php"
]
}
require_once __DIR__ . '/vendor/autoload.php';
+ require_once __DIR__ . '/vendor/stevegrunwell/time-constants/src/GlobalAliases.php';
Please note that this GlobalAliases.php
file will be removed in the next major release (e.g. v3.x
) of this library.
Published by stevegrunwell 10 months ago
MILLISECONDS_PER_SECOND
(1,000ms/s)MICROSECONDS_PER_SECOND
(1,000,000µs/s)NANOSECONDS_PER_SECOND
(1,000,000,000ns/s)PICOSECONDS_PER_SECOND
(1,000,000,000,000ps/s)archive.exclude
section in composer.json
(#15).Published by stevegrunwell almost 3 years ago
composer.json
(#9)master
to main
Published by stevegrunwell almost 5 years ago
ONE_MINUTE
.composer.json
(#5, props @peter279k).Published by stevegrunwell almost 6 years ago
ONE_SECOND
and ONE_MINUTE
, which are both equal to 1
(#2).Published by stevegrunwell over 6 years ago
First release of the package, containing 11 constants:
MINUTE_IN_SECONDS
(60 seconds)HOUR_IN_SECONDS
(3600 seconds)DAY_IN_SECONDS
(86,400 seconds)WEEK_IN_SECONDS
(604,800 seconds)MONTH_IN_SECONDS
(2,592,000 seconds)YEAR_IN_SECONDS
(31,536,000 seconds)HOUR_IN_MINUTES
(60 minutes)DAY_IN_MINUTES
(1,440 minutes)WEEK_IN_MINUTES
(10,080 minutes)MONTH_IN_MINUTES
(43,200 minutes)YEAR_IN_MINUTES
(525,600 minutes)