I asked this question a while ago. Now I need to run it on production server, but the server is 5.2.9 …
How can I write an alternative function that would give me the exact result as the DateTime::createFromFormat function?
Yes, I know there are duplicates, but they all use strptime. But when I try to use it, I get: Fatal error: Call to undefined function strptime().
And no, I have no access on this production server, so I can’t change any settings for it.
Include this and you can use
strptime:However, since DateTime::createFromFormat returns an object of DateTime, you can’t get the exact same result in PHP < 5.3 (unless your willing to write your own class which behaves exactly like DateTime)