Getting missmatch in datetime format using jms serializer and ISO8601

I get this message:

Invalid datetime "2017-11-07T19:46:57.118Z", expected format Y-m-d\\TH:i:sP.

When using JMS Serializer and configuration:

jms_serializer:
    handlers:
        datetime:
            default_format: 'Y-m-d\\TH:i:sP'

I think that my date is provided in the correct format, but apparently not. Is there something wrong with the date?

+4
source share
1 answer

This is a tough question that I came across before. I used annotations, so my fix looked like this:

 @Serializer\Type("DateTime<'Y-m-d\TH:i:s.uT'>")

So, I assume yours will look like this:

jms_serializer:
    handlers:
        datetime:
            default_format: 'Y-m-d\TH:i:s.uT'

Or you may have to add another slash before “TH” if jms reads yaml files other than annotations.

, , , , . , .

+4

Source: https://habr.com/ru/post/1688888/


All Articles