strtotime mismatch in php


This code ends up in two ways depending in what server it is run:
date("H:i:s d-m-Y", strtotime('1492-10-12T00:00:00+00:00'))
WebServer 1(correct result): 00:00:00 12-10-1492
WebSite in Azure: 16:00:00 31-12-1969

I have no idea why this is happening. Does it have something to do with the php setup being different on the two servers, or maybe timezones or dateformat being different on the servers? How do I fix this so that I get the same result on both servers?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

$date = new DateTime('1492-10-12T00:00:00+00:00');

echo $date->format('H:i:s d-m-Y');

Open in new window

strtotime only works for dates from 1970 on Windows

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
This sort of date value ("31-12-1969") is almost always the signature of the failure of strtotime(), accompanied by a programming error.  It happens because when strtotime() fails, it returns FALSE.  The programming error happens because the programmer assumed that strtotime() always worked, did not test for FALSE in the script, and used the output from strtotime().  PHP is a loosely typed language, so the value of FALSE, when fed to the date() function, was turned into zero.

On the current levels of 64-bit PHP, this works just fine. 

From the man page: "For 64-bit versions of PHP, the valid range of a timestamp is effectively infinite, as 64 bits can represent approximately 293 billion years in either direction."

You might also find this article helpful.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.