February 28, 2008
PHP Stupidity php.gif
This is pretty stupid.

<?php
echo date('Y-m-d', '2007-01-01 23:12:24');
?>

This will return an error:

Notice: A non well formed numeric value encountered in ....

Yet, return a date of  ' 1969-12-31'. Making it @date(...) shuts it up, but returns wrong data. However, this works:

<?php
echo date('Y-m-d', strtotime('2007-01-01 23:12:24'));
?>

Why should I have to go through the extra typing? Why doesn't date() implicitly know to at least try strtotime() on the string BEFORE telling me any warnings? It's a string, here... give me what I want. And, why does it return 1969-12-31 at all? If it was bad data, just return nothing. Don't return bad data.
Posted by Kevin at February 28, 2008 03:48 PM
Comments
Post a comment

Leave a ramble