Fixed DateTime::__construct(): Failed to parse time string

Andy.N

Well-known member
I have many members imported from VB 3.8 whose DOB fields are out of order (such as year is 3453 and month is 45).
When I go directly to that member's profile page, it will show a server error message (and generates a record ACP as well).

Here is what shows on the member profile page
Server Error
DateTime::__construct(): Failed to parse time string (1116-19-82) at position 6 (9): Unexpected character
  1. DateTime->__construct() in XenForo/Model/UserProfile.php at line 27
  2. XenForo_Model_UserProfile->getUserBirthdayDetails() in XenForo/ControllerPublic/Member.php at line 227
  3. XenForo_ControllerPublic_Member->actionMember() in Bookmarks/ControllerPublic/Member.php at line 18
  4. Bookmarks_ControllerPublic_Member->actionMember() in XenForo/FrontController.php at line 310
  5. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
 
I've fixed this at the importer stage. This query will fix broken dates:
Code:
UPDATE xf_user_profile SET dob_day = 0, dob_month = 0, dob_year = 0 WHERE dob_day > 31 OR dob_month > 12 OR dob_year > 2012 OR (dob_year > 0 AND dob_year < 1900);
 
Top Bottom