probleme Date vs Datetime in symfony

Viewed 162

I want to send a json to my api like this :

{
    "civility": "Mr",                   
    "lastname": "toto",             
    "firstname": "titi",                
    "email": "mon@email.com",   
    "birthday_date": "1970-01-01"
}   

But I have this response:

{"code":400,"message":"Invalid datetime \"1970-01-01\", expected format Y-m-d\\TH:i:sP."}

My validation.yml:

    birthdayDate:
        - Date: ~

My entity:

/**
 * @var date
 *
 * @ORM\Column(name="birthdayDate", type="date")
 * 
 */
private $birthdayDate;

The solution I've found is to format the datetime:

$birthday_date->format('Y-m-d\TH:i:sP')

But if it's possible I'd prefer to send with the format ('y-m-d').

0 Answers
Related