grav-plugin-admin icon indicating copy to clipboard operation
grav-plugin-admin copied to clipboard

Saving in site date format crashes site.

Open dcrobertson01 opened this issue 1 year ago • 5 comments

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 avatar Jan 28 '24 04:01 dcrobertson01

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.

dcrobertson01 avatar Jan 28 '24 04:01 dcrobertson01

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.

rhukster avatar Feb 03 '24 20:02 rhukster

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 avatar May 13 '24 03:05 dcrobertson01

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 avatar May 13 '24 04:05 dcrobertson01

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.

dcrobertson01 avatar May 17 '24 04:05 dcrobertson01