src/Utilities/Date.php
public static function getRandomDate(DateTime $startDate = null, $start = 1, $end = 100, $intervalTemplate = 'P%sD')
    {
        if (null === $startDate) {
            $startDate = new DateTime();
        }

        $start = (int)$start;
        $end = (int)$end;

        /*
         * Incorrect end of random partition?
         * Use start as the end of random partition
         */
        if ($end < $start) {
            $end = $start;
        }

        $randomDate = clone $startDate;
        $randomInterval = new DateInterval(sprintf($intervalTemplate, mt_rand($start, $end)));

        return $randomDate->add($randomInterval);
    }
public static function getRandomDate(DateTime $startDate = null, $start = 1, $end = 100, $intervalTemplate = 'P%sD')
    {
        if (null === $startDate) {
            $startDate = new DateTime();
        }

        $start = (int)$start;
        $end = (int)$end;

        /*
         * Incorrect end of random partition?
         * Use start as the end of random partition
         */
        if ($end < $start) {
            $end = $start;
        }

        $randomDate = clone $startDate;
        $randomInterval = new DateInterval(sprintf($intervalTemplate, mt_rand($start, $end)));

        return $randomDate->add($randomInterval);
    }
public static function getRandomDate ( DateTime $ startDate = null , $ start = 1 , $ end = 100 , $ intervalTemplate = 'P%sD' ) { if ( null === $ startDate ) { $ startDate = new DateTime ( ) ; } $ start = ( int ) $ start ; $ end = ( int ) $ end ; /*
         * Incorrect end of random partition?
         * Use start as the end of random partition
         */ if ( $ end < $ start ) { $ end = $ start ; } $ randomDate = clone $ startDate ; $ randomInterval = new DateInterval ( sprintf ( $ intervalTemplate , mt_rand ( $ start , $ end ) ) ) ; return $ randomDate -> add ( $ randomInterval ) ; }
Returns random date based on given start date

@param DateTime $startDate        (optional) Beginning of the random date. If not provided, current date will
be used (default behaviour).
@param int      $start            (optional) Start of random partition. If not provided, 1 will be used
(default behaviour).
@param int      $end              (optional) End of random partition. If not provided, 100 will be used
(default behaviour).
@param string   $intervalTemplate (optional) Template used to build date interval. The placeholder is replaced
with next, iterated value. If not provided, "P%sD" will be used (default
behaviour).
@throws Exception
@return DateTime
Returns random date based on given start date