mirror of
https://github.com/fzaninotto/Faker.git
synced 2025-03-23 16:59:53 +01:00
Allow dateTimeBetween to accept DateTime instances
This commit is contained in:
parent
468dd5b726
commit
83fd81c0c0
@ -79,8 +79,8 @@ class DateTime extends \Faker\Provider\Base
|
||||
*/
|
||||
public static function dateTimeBetween($startDate = "-30 years", $endDate = "now")
|
||||
{
|
||||
$startTimestamp = strtotime($startDate);
|
||||
$endTimestamp = strtotime($endDate);
|
||||
$startTimestamp = $startDate instanceof \DateTime ? $startDate->getTimestamp() : strtotime($startDate);
|
||||
$endTimestamp = $endDate instanceof \DateTime ? $endDate->getTimestamp() : strtotime($endDate);
|
||||
$timestamp = mt_rand($startTimestamp, $endTimestamp);
|
||||
|
||||
return new \DateTime('@' . $timestamp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user