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

Dates far the past using MM/dd/YYYY are displayed one year ahead #178

Closed
sethjohnson1 opened this Issue Sep 27, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@sethjohnson1

sethjohnson1 commented Sep 27, 2018

I have noticed that when dates toward the turn of the century or before are displayed as MM/dd/YYYY, they appear incorrectly - one year ahead of where they should be. For example 12/31/1889 is saved to the database, and then rendered as 12/31/1890. Obviously this causes problems with CakePHPs edit views, where the values are automatically populated in form controls. Each time the user saves, the date is incremented ahead.

I noticed if I use Cake\I18n\FrozenDate::setToStringFormat(\IntlDateFormatter::SHORT) instead of Cake\I18n\FrozenDate::setToStringFormat('MM/dd/YYYY') then the dates are displayed correctly.

@markstory

This comment has been minimized.

Member

markstory commented Sep 27, 2018

Does your database support saving values formatted with mm/dd/yyyy? The date columns I've worked with in the past required YYYY-MM-DD.

How can someone reproduce the issue you're having/seeing?

@markstory markstory added the bug label Sep 27, 2018

@sethjohnson1

This comment has been minimized.

sethjohnson1 commented Sep 27, 2018

I am using cakePHP to save them to a Microsoft SQL 2016 database, which is using the datatype of date – and requires the format to be YYYY-MM-DD. The saving is not the problem, I think it’s just a formatting issue. The problem can be reproduced by saving the date “12/31/1889” to a database using a generic “baked” cakePHP CRUD application. Then go to the “Edit” view, and the autofilled date is “12/31/1890”

I can create one quickly on a MySQL database if you think Microsoft SQL is the culprit, but I think it has something to do with formatting since setting Cake\I18n\FrozenDate::setToStringFormat(\IntlDateFormatter::SHORT) in bootstrap.php displays the date correctly.

I should also clarify that it seems to be any date around the turn of the century or earlier, and near the end of the year. I haven't had enough time to figure out exactly when the cutoff might be - I thought I would open the issue here first. Let me know if there is something specific I can do to help.

@lorenzo

This comment has been minimized.

Member

lorenzo commented Sep 28, 2018

The format is wrong, please use yyyy as uppercase Y means "week year" which is a different thing. You can read about the format here http://userguide.icu-project.org/formatparse/datetime

@lorenzo lorenzo closed this Sep 28, 2018

@sethjohnson1

This comment has been minimized.

sethjohnson1 commented Sep 28, 2018

Yes but this happens with the default settings in CakePHP, so I apologize that my Comment was using the wrong format - but I believe there is still a bug in the software itself. Did you try to replicate the issue? Would you like me to bake a generic application and host it online to demonstrate it for you?

Ok I stand corrected! Thank you for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment