strtotime() and Pre-1970 Dates
Using strtotime() to process dates before 1970 can pose challenges due to its limited range. To address this issue, check your PHP version and platform. Consider upgrading if necessary.
Alternatively, for more flexibility in handling wider date ranges, consider using PHP's DateTime objects. They allow for dates far beyond the 13 Dec 1901 to 19 Jan 2038 range.
Procedural Approach:
$date = date_create($row['value']); if (!$date) { $e = date_get_last_errors(); foreach ($e['errors'] as $error) { echo "$error\n"; } exit(1); } echo date_format($date, "F j, Y");
OOP Approach:
try { $date = new DateTime($row['value']); } catch (Exception $e) { echo $e->getMessage(); exit(1); } echo $date->format("F j, Y");
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3