joshtronic/randomdate

完全兼容PHP的date函数的随机时间/日期生成器。

1.0.0 2020-05-30 17:19 UTC

This package is auto-updated.

Last update: 2024-08-29 05:43:18 UTC


README

License PHP Version Test Status Code Coverage Monthly Downloads

完全兼容PHP的date函数的随机时间/日期生成器。

兼容PHP 5.3以上版本。

安装

composer require joshtronic/randomdate

使用方法

<?php
$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();

与PHP函数的兼容性

设计上,这个库旨在通过使用PHP现有的熟悉的格式字符串以及极其强大的strtotime来设置用于生成的日期范围,以保持简单。