- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 311
Date deserialization (DateTime object) #582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Interesting... PHP behaves differently when using the constructor and |
Right. From the PHP docs:
So basically, if I set the format to contain the exclamation mark, it should be fixed for my case. Should we do this by default? There is also a pipe ( |
Okay, so it works when I use one of those specific characters during deserialization only, but as the type is also used during serialization, it fails with an unrecognized format (as the output becomes |
is not the first time I see this type of problem... basically the root cause is that the dateformat can be different when serializing and when deserializing... PR with to allow serialization and (optional) deserialization format are welcome! :) |
I've been looking into the optional deserialization parameter for the annotation, which should be fairly simple to add when using the existing annotation driver:
Then you will always need to supply the timezone, when you want to supply the deserialization format. I would like to put instead of the timezone, but yeah, BC-breaking changes 😄 What is you opinion on adding a new type, specific for deserialization? So the |
solved with schmittjoh/serializer#788 |
I'm having an issue with the deserialization of a DateTime object which only contains a date: the time is set to zero, and is not serialized. I have the following property:
When I deserialize this, I will get a DateTime object which has the current time set, due to this line (L184) in the
DateHandler
:What would be best practice to resolve this issue? Does adding a timezone work, or should I serialize the complete DateTime class including the zero time, to ensure correct functioning (which adds extra data). Or should we adjust the serializer to set the time to zero when it is not given?
The text was updated successfully, but these errors were encountered: