• We are getting the following error for ever user on our website. If I disable the amr users plugin, the issue goes away.

    The site has been working fine for years, not sure what has changed.

    DateTime::__construct(): Failed to parse time string (152) at position 0 (1): Unexpected character

    Message to admin only: Fatal error caught – Unable to create DateTime object from this string: “152” with timezone DateTimeZone Object ( [timezone_type] => 3 [timezone] => America/New_York ) Please check the content of your date fields, and any fields where you have specified a date format

    We are on WordPress 5.8.1, AMR Users 4.57

    We used the General Settings to change the timezone to Detroit as a test, and the error changed accordingly…

    DateTime::__construct(): Failed to parse time string (152) at position 0 (1): Unexpected character

    Message to admin only: Fatal error caught – Unable to create DateTime object from this string: “152” with timezone DateTimeZone Object ( [timezone_type] => 3 [timezone] => America/Detroit ) Please check the content of your date fields, and any fields where you have specified a date format

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author anmari

    (@anmari)

    it sounds like you have garbage data in a field, as the message says
    Fatal error caught – Unable to create DateTime object from this string: “152” with timezone DateTimeZone Object ( [timezone_type] => 3 [timezone] => America/Detroit ) Please check the content of your date fields, and any fields where you have specified a date format

    search in phpmyadmin on those fields for ‘%152%’

    • This reply was modified 3 years, 2 months ago by anmari.
    Plugin Author anmari

    (@anmari)

    Hi again, I’ve played around putting junk data in to date fields. The only way I can get that admin message up is i have said a field has a dates in it like yyyy-mm-dd in it ie the plugin expects a date in format like YYYY-MM-DD
    If php cannot convert the data into a date object, for example because it finds in the data ‘152’ instead.then the plugin traps the error as above.

    Note that the public user does not see that message – they will just see ‘152’ with a little exclamation mark next to it.

    It is possible that your dates are actually unix timestamps??? or maybe there is just junk data in one users record.

    If you don’t know how to look for the data in phpmyadmin, you can try using the user list & search for ‘152’ or try sorting the date fields and the record with the bad data may show up at the beginning or end of the list.

    Please let me know how you go.

    Thread Starter grungyape

    (@grungyape)

    Don’t hate me for saying this, but the dates are exactly what WordPress set them as.

    By this I mean, when we installed AMR Users 4 years ago, and then had our users start signing up for accounts, this error did not exist.

    Sometime in the past few months, this error appears for every single user in the system on the admin Users page. The example I gave is 1 of 200. if I disable the AMR Users plugin, the error goes away.

    If I use the admin General page to alter the WordPress TimeZone, it alters the error accordingly, i.e. [timezone] => America/New York to [timezone] => America/Detroit

    The field specifically having the issue is the User Registered field on the Users page, as it now appears blank.

    So I’m happy to, and able to, use PhPAdmin to check the field:

    Here is a handful of the values I see: https://i.imgur.com/YEPvPub.png

    Now I also took a look at our user registration, we use Gravity Forms User Registration Add-on. We always have, so this is not new. But I wanted to make sure “I” was not formatting the entry date, and I’m not. It is the system datetime stamp.

    Plugin Author anmari

    (@anmari)

    Hi, thanks for the additional info that it is happening on the user registration field. That would still tend to indicate some data corruption as it is not happening to anyone else or on any of the demo systems. This has happened to me a couple times – fixed with a database repair.

    Other possibility is maybe something (php version?) is ‘old’ if your system has been around awhile. So what to do?

    1) lets check basics of system first. – how does your php & mysql etc compared to wp recommended? https://en-au.www.ads-software.com/about/requirements/. Please also post the data in the page Userlists> General & About > Your user db

    2) Check if database needs repairing – you can google steps, here’s one i found https://kinsta.com/knowledgebase/wordpress-repair-database/

    3) if above all sorted & message still occurs: the message in the code is when the plugin tries to convert the data in a field to a date object. It is complaining that the string passed is not usable – it says it received ‘152’ which is clearly not a date. It is not complaining about the timezone, that’s not the problem. It is also weird that the field is blank – in my systems, it usually just shows the raw data when it is unable to convert the data.

    SO…. we need to find the user record with ‘152’.

    If you have other messages with complaints about other data, you can try searching for those reported strings. I see that the handful you listed look fine. You need to find the ones that are not fine.

    Search in phpmyadmin on the user_registered column in the wp_users in my version doesnt work lol – insists on a datetime value – i can’t force crap in!

    3.1 – you may have luck finding the ‘bad’ records using the userlist to search. like here https://s2m.wpusersplugin.com/, where I can search https://s2m.wpusersplugin.com/?su=202109 to find the record with ‘202109’ in the user record.
    IF you have done all of the above and we are no closer to understanding whats happening, I can take a look. I would need full access to the install and to phpmyadmin and you would need to ensure that you have made backups that you know how to restore.

    • This reply was modified 3 years, 2 months ago by anmari. Reason: clarify , typos
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘DateTime::__construct(): Failed to parse time string (152) at position 0 (1): Un’ is closed to new replies.