Date changes to current year when updating book
Opened this issue · 9 comments
In certain situations, the year changes when updating a book post.
When using a date format such as j. F Y, the date must be entered as 20.06.2007 to be correctly rewritten to 10. Juni 2007 for the book.
However, if you update the book, the year switches to 2015 (current year). To change it back, you must re-enter the full date as 20.06.2007
@dreamwhisper sorry, I may be misunderstanding what is happening. It might be a typo. If you enter 20.06.2010 it outputs "10. Juni 2007" as the date for j. F Y formatted output?
@NicktheGeek it happens when you update the book, not on first save.
@dreamwhisper I understand, I'm just trying to make sure I'm understanding correctly what is happening. The output date is "10. Juni 2007" when setting "20.06.2010"?
hi https://github.com/NicktheGeek, here 1. example: I setup a new book, enter the date: 20.10.2010 an publish the book. WordPress write the date in correct format j. F Y: 20. Oktober 2010
Then I edit this date and change it to: 10. Oktober 2010 on safe the date turns blank.
https://github.com/dreamwhisper
But other months have other bugs.
The month Juni turns years back to 2015
Example: 10. Juni 2008 turn into 10. Juni 2015 on saving the film.
I can test month for month tomorrow, give you feedbacks or give you access, however you like?
@NicktheGeek Sorry, I did make a typo. I fixed it.
I had to do it now;-) here a full list.
Januar=blank
Februar=blank
März=blank
April=okay:)
Mai=blank
Juni=turns to 2015
Juli=turns to 2015
August=okay:)
September=okay:)
Oktober=blank
month 11 are not rewritten into November
but November=okay.)
month 12 are not rewritten into Dezember
but Dezember=okay.)
Thanks, I'm wondering if the issue is the server isn't sure what to do with the localized month names. I am using the date_i18n()
function when outputting the date in the dashboard. I imagine that I could resolve this by switching to date()
but the output date in the dashboard would show the English month rather than the localized month.
We can still use the date_i18n()
function on the actual output meta data so what appears on the site is correctly localized.
This would be the simplest solution.
An alternate solution might be to use the strptime()
function when updating this value instead of strtotime()
which cannot handle non English formats. There are some drawbacks there as the format has to be defined using a specific format markup that is different from the date format normally used with date()
. It also means that the format must be defined so it will work for saved formats but not open ended data entry, which is something I was shooting for with this field instead of using a calendar input.
That's why I think the better solution would be to switch to date()
in the dashboard in keep date_i18n()
for the front end output.
Noting additional development conversations: Add option to disable autoformatting of date.
@dreamwhisper Super idea to "add option to disable autoformatting of date",
I only need a year, I do not really need the date at all. So this would make it perfect for my purpose.