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

Saving in site date format crashes site. #2394

Open
dcrobertson01 opened this issue Jan 28, 2024 · 5 comments
Open

Saving in site date format crashes site. #2394

dcrobertson01 opened this issue Jan 28, 2024 · 5 comments

Comments

@dcrobertson01
Copy link

Hi - whenever I save a file with a date greater than the 12 of the month, I get a 'Crickey there was an error', and the whole page is an error - with

An exception has been thrown during the rendering of a template ("Failed to parse time string (13/11/2024) at position 0 (1): Unexpected character").

When I open the page in a text editor, and change or remove the date, the page still fails.

No matter what I do, I still get this error. I've cleared the cache, deleted the cache, restarted the server and so on but it still errors on the date - even when it is no longer there. Caching is also disabled.

The only way to save the page is to delete it in the admin interface, add a new one and make sure the date is not greater than the 12th of the month.

Any solution to this?

@dcrobertson01
Copy link
Author

Downloading the latest Grav+admin bundle, removing the user directory, and copying my entire user directory into the folder to replace it seems to have fixed it.

@rhukster
Copy link
Member

rhukster commented Feb 3, 2024

Ok, so first off the default is US Dates with slashes (/) which works in m/d/Y format so that means 12/03/24 is acutally December 3rd, 2024. Alternative you can use dashes (-) for default Euro format: d-m-Y.

If you want to use Euro format even with slashes, you just set it in the configuration: system -> pages -> dateformat -> default. Set this to d/m/Y. Or you can use any custom PHP date compatible format: https://www.php.net/manual/en/datetime.formats.php

That all said, it shouldn't error out on a bad date, it should just fallback to the timestamp of the file if it can't parse the date correctly, so i've fixed that for the next release.

@dcrobertson01
Copy link
Author

Hi - I am still getting this problem, but only on my main installation. My development site is fine. And it only happens on the admin page - if I change the date in the page with an editor, the change is reflected in the published page, but no matter what I do, I get an error on the admin page. I try clearing the cache etc, but still get the error.

If I add or modify a page on the dev machine and copy it to the server it is fine -

I've set the pages-> dateformat->default to d/m/Y (always has been), and I have copied my whole user directory to the server.

Could it be some php setting? Both have the time and date set to UTC, and the timezone set to Auckland/Pacific.

@dcrobertson01
Copy link
Author

And another thing - the date picker in the admin page puts the date as 01/02/2024 12:00 am on my local machine, but as 01/02/2024 on the server ...

@dcrobertson01
Copy link
Author

BTW - my development site is using the grav server, the main site is using nginx - don't know if that makes a difference.

I don't think I am actually using the short date anywhere, so I've just changed the page format to m/d/Y h:i a. Seems to work now.

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

2 participants