你好社区我有一个问题我在发送到基站时在Symfony 4中创建数据夹具我有这个错误:DateTime :: __ construct():无法解析位置0的时间字符串(22/10/2009) (2):意外的角色:
my class:
class AppDataFixtures extends fixture
{
/**
* Load data fixtures with the passed EntityManager
*
* @param ObjectManager $manager
*/
public function load(ObjectManager $manager)
{
$this->loadUsers($manager);
}
private function loadUsers(ObjectManager $manager)
{
foreach ($this->getUserData() as [$name, $username, $email, $birthdate, $password, $address, $userCode, $roles, $isActive]) {
$user = new User();
$user->setName($name);
$user->setUsername($username);
$user->setEmail($email);
$user->setBirthdate($birthdate);
$user->setPassword($this->passwordEncoder->encodePassword($user, $password));
$user->setAddress($address);
$user->setUserCode($userCode);
$user->setRoles($roles);
$manager->persist($user);
}
$manager->flush();
}
private function getUserData(): array
{
return [
// $userData = [$name, $username, $email, $birthday, $password, $adress, $userCode, $roles, $isActiv];
['Jane Doe', 'jane_admin', 'jane_admin@symfony.com', new \DateTime('12/10/2008'),'test', '45 rue de tourtille', 1398799, ['ROLE_USER'], true],
['Tom Doe', 'tom_admin', 'tom_admin@symfony.com', new \DateTime('22/10/2009'),'test','46 rue de tourtille', 13587999, ['ROLE_USER'], true],
['John Doe', 'john_user', 'john_user@symfony.com', new \DateTime('15/11/2000'),'test','43 rue de tourtille', 139798999, ['ROLE_USER'], true]
];
}
}
请帮帮我
答案 0 :(得分:0)
将日期格式更改为12/10/2008至2008-10-12