fun with dates

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

fun with dates

Post by magicrobotmonkey »

here's something that happens. why?

Code: Select all

//this is actually pulled from a mysql db, but a var_dump tells me its:
//string(19) "0000-00-00 00:00:00"
//so this is the same
$blankDate = "0000-00-00 00:00:00";

echo date("m-d-Y",strtotime($blankDate));

//prints 11-30-1999
//why? what's up with that date? its not the Start Date or anything?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

because you feed the function invalid data...

http://www.gnu.org/software/tar/manual/ ... tar_7.html
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

or, in more detail, strtotime thinks like this:

0000 = 2000
00 = 2000 - 1 month or 12-1999
00 = 12-1999 - 1 day or 11-30-1999
Post Reply