Search code examples
faker

Faker YML add 1 hour to a date


My question is about Faker. I need to add one hour to a created date Like this :

MyEntity: 
    startAt: '<dateTimeBetween("- 10 days", "now")>'
    endAt: $startAt + 1 hour

Thx for your help.


Solution

  • Well that does not exist yet. Need to create a custom provider

    Like this :

    public static function manipulateTime($date, $action = '-30 years')
        {
            $date = new \DateTime($date->format('Y-m-d H:i:s'));
            $date->modify($action);
    
            return $date;
        }