Skip to content
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

Localization of parsing format (parse, constructor...) #1074

Closed
Yo1L opened this issue Jan 18, 2018 · 4 comments
Closed

Localization of parsing format (parse, constructor...) #1074

Yo1L opened this issue Jan 18, 2018 · 4 comments

Comments

@Yo1L
Copy link

Yo1L commented Jan 18, 2018

Hey,

First of all, carbon is awesome! Great work folks!

I’m working with Laravel and managing dates in French can be such a pain in the #$%.
Indeed, when I'm trying to get my date from a browser request, I need to convert it (submit interception) in order to be parsed by Carbon. For this, I chose a common format (ISO 8601) for JS and PHP, which is fine.

I could avoid such tweak if I could set the “From Format” like specified in createFromFormat().

Today, we can set the “TO” format and i think it could be a really great improvement if we could do so.

Thanks

@ricardobucho
Copy link

Hey,

Sorry but I didn't really get your question.

What are you trying to accomplish really?
What is the user input and what is expected?

I'm asking this because you can set a format on the createFromFormat method.
Are you asking for Carbon::parse to accept french words?

Enlighten me please :P Thank you.

@Yo1L
Copy link
Author

Yo1L commented Feb 17, 2018

Thanks for at least trying to understand.

It could be great addition if we had a static parseFromFormat string to avoid using createFromFormat and using the constructor like Laravel do.

My input are like dd/mm/YYYY

If I could set my parseFromFormat like this :
Carbon::setFromFormat( $format ) when my application starts, I could enjoy a full localization of my dates and use all of its validation rules and stuff!

createFromFormat works great and I’m using right now as a tweak and it’s a bit overwhelming because I have to do it for each user date input...

I tried many solutions and none are elegant. I really think it can be a great feature for both of us : Carbon, Laravel and other weird date formats :)

Thanks

@kylekatarnls
Copy link
Collaborator

Sorry, still don't get it. Please add code, or the code you wish and the output you expect.

@kylekatarnls
Copy link
Collaborator

kylekatarnls commented Mar 9, 2018

I have to do it for each user date input

Have to do what, could you provide code please?

I close this issue for the moment. If you provide concrete code and expected result, I'll re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants