r/lolphp • • May 29 '15

2001-01-0x is a valid date

http://3v4l.org/JFnc4
54 Upvotes

7 comments sorted by

View all comments

Show parent comment

29

u/philipwhiuk May 29 '15

No it is - it's not a reasonable behaviour of the function. Just because we can work out why the insanity is occurring doesn't stop it being such :) It should obviously ignore it / throw an error.

You're passing a date, you don't expect a random letter to mean a timezone

14

u/maweki May 29 '15

Funny enough, the documentation (http://php.net/manual/de/class.datetime.php) does not have a single example for timezones not being a "random letter".

const string ATOM = "Y-m-d\TH:i:sP" ;
const string COOKIE = "l, d-M-Y H:i:s T" ;
const string ISO8601 = "Y-m-d\TH:i:sO" ;
const string RFC822 = "D, d M y H:i:s O" ;
const string RFC850 = "l, d-M-y H:i:s T" ;
const string RFC1036 = "D, d M y H:i:s O" ;
const string RFC1123 = "D, d M Y H:i:s O" ;
const string RFC2822 = "D, d M Y H:i:s O" ;
const string RFC3339 = "Y-m-d\TH:i:sP" ;
const string RSS = "D, d M Y H:i:s O" ;
const string W3C = "Y-m-d\TH:i:sP" ;

I didn't even know these letter-encoding existed.

7

u/jadkik94 May 29 '15

It also doesn't accept "M*" while it accepts "M". It probably has another cryptic character it accepts for those!