PHP Date Function

I encounter a problem with the php data function.

echo strtotime ("05/31/2011");

It prints blank.

What is the problem with this?

Thank.

+5
source share
5 answers

DD / MM / YYYY is not a valid date format (The manual outlines it must follow one of the supported date and time formats ) So, instead, it should be MM / DD / YYYY :.

echo strtotime("05/31/2011");

Or, I think, as others have published, hyphens are used in the European version (ISO8601 notations):

echo strtotime("31-05-2011");
+4
source

http://php.net/manual/en/function.strtotime.php

Use hyphens instead of a slash.

echo strtotime("31-05-2011"); // outputs 1306821600
+1
source

(DD-MM-YYYY) :

echo strtotime('31-05-2011');
+1

echo strtotime("2011-05-31");

+1

php DateTime?

DateTime::createFromFormat('d/m/Y', '31/05/2011');
+1

All Articles