Sergey Scopin
Sergey Scopin

Reputation: 2245

strtotime returns false on certain dates

I check here my strtotime function: 11/2/2016 returns timestamp but some dates higher returns false. 12/2/2016 is false however 2016-2-12 returns timestamp. WTF? That's not problem for me to past them but according to docs it's fine format.

Upvotes: 1

Views: 516

Answers (1)

cn0047
cn0047

Reputation: 17091

We have such problem on our project and we solve it by using DateTime::createFromFormat

$dateTime = \DateTime::createFromFormat('d/m/Y', '12/2/2016');
// now you can receive absolutely correct timestamp
$dateTime->getTimestamp()

Upvotes: 2

Related Questions