Random time/date generator fully compatible with PHP's date function.
Find a file
Josh Sherman 69c4a24301
feat: initial commit
Basic functionality and tests and all that.
2020-05-12 22:28:19 -05:00
src feat: initial commit 2020-05-12 22:28:19 -05:00
tests feat: initial commit 2020-05-12 22:28:19 -05:00
.coveralls.yml feat: initial commit 2020-05-12 22:28:19 -05:00
.gitignore feat: initial commit 2020-05-12 22:28:19 -05:00
.travis.yml feat: initial commit 2020-05-12 22:28:19 -05:00
composer.json feat: initial commit 2020-05-12 22:28:19 -05:00
FUNDING.yml feat: initial commit 2020-05-12 22:28:19 -05:00
LICENSE feat: initial commit 2020-05-12 22:28:19 -05:00
phpunit.xml feat: initial commit 2020-05-12 22:28:19 -05:00
README.md feat: initial commit 2020-05-12 22:28:19 -05:00

php-randomdate

Random time/date generator fully compatible with PHP's date function.

Compatible with PHP 5.3+.

Installation

composer require joshtronic/php-randomdate

Usage

$rd = new joshtronic\RandomDate();

// Between the Unix Epoch and now
$rd->date(/* format string, default = 'c' */);

// Between January 1st, 1900 and now
$rd->min('1900-01-01')->date('Y-m-d');

// Between the Unix Epoch and next month
$rd->max('next month')->date('r');

// Between yesterday and tomorrow (at midnight)
$rd->between('yesterday', 'midnight tomorrow')->date('r');

// Reset minimum and maximum to defaults
$rd->reset->date();

Compatibility with PHP functions

By design, this library aims to keep things simple by using the familiar format string provided by PHP's existing date as well as the extremely powerful strtotime for setting the range of dates used for generation.