With the PHP Year 2038 bug, there will come a time where a developer may encounter a specific problem especially when using the strtotime
function. Despite that what I would suggest right now is something that I could share with you and is also publicly available on our ever aid StackOverflow.
As a proper work around for this problem, the same strtotime
function could be achieved by using the DateTime Class in PHP. The syntax goes as follows:$date = new DateTime('2012-01-25 19:44:49.123');
echo $date->getTimestamp();
As I’ve also read in its definition and useage, the strtotime()
function parses an English textual datetime into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT) and thankfully, getTimestamp returns the same output base on initial trials. Please do keep in mind that on the original strtotime
function, it is format sensitive where as the ( – ) format and ( / ) format returns a different result.
For more information, I would always love to suggest reading the proper documentation on official sites/channels. Details gathered on this article are always available in W3Schools and PHP website.
Discussion about this post