ISO 8601
#797
Replies: 1 comment
-
You can solve this by using the following approach, assuming: you're using Eloquent and are returning Carbon instances (or a compatible representation):
I suggest to take inspiration from https://github.com/nuwave/lighthouse/blob/94084e7ef882311ce0cb5b413ee9a56c696e0759/src/Schema/Types/Scalars/DateTimeTz.php#L7 (also check the parent And yes, I'm also with your frontend team regarding this. It's more or less unambiguous, plus includes the time zone |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm a bit confused. Our front end developers suggest that we should use ISO 8601 date format.
"Y-m-d\TH:i:s"
2021-06-19T20:00:00
not
2021-06-19 20:00:00
After some research, I find it difficult to be implemented easily.
I can write a mutator for each date attribute for each model.
I can write a resolver for each attribute in graphql type.
Having ~50 different graphql types and more date attributes it is a lot of dumb code + a big room for a mistake. Sooner or later there can be a mistake and some date would be formatted as 2021-06-19 20:00:00. Losing coherence. May be you can have an idea for simple solution? One that seems most efficient for me is to run regexp through entire server response before it is sent to client (obviously it has it's own disadvantages).
Beta Was this translation helpful? Give feedback.
All reactions