Re: Sniping on the List

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Nov 17, 2011, at 10:01 AM, Tedd Sperling <tedd.sperling@xxxxxxxxx> wrote:

On Nov 15, 2011, at 2:54 PM, Steven Staples wrote:
<tamouse.lists@xxxxxxxxx> sent:
<tedd.sperling@xxxxxxxxx> wrote:
PS: I know it's not Friday, but this question came up in class
yesterday and I thought maybe all of you might like to guess why
null is Wednesday?

Wait.. What??

$ php -r 'echo date("l",NULL),"\n";'
Wednesday

Cos:

$ php -r 'echo date("r",NULL),"\n";'
Wed, 31 Dec 1969 18:00:00 -0600

(Personally, I would have thought Thursday should be NULL, but that's
just me. And Thursday.)

Actually, It *is* Thursday if you use UTC:

$ TZ=UTC php -r 'echo date("r",NULL),"\n";'
Thu, 01 Jan 1970 00:00:00 +0000

:P

Perfect example of Tedd's last comment about being proven wrong (even though TECHNICALLY it isn't)

Good job :)

To all:

Okay, so now that we have had people reply, here's my take.

The Unix timestamp started on 01 Jan 1970 00:00:00 +0000 -- and that was a Thursday.

The second before (i.e., 31 December, 1969 23:59:59:59 + 0000) was null, which was Wednesday.

Now one might argue that everything before was null and I could accept that. But here's my code and reasoning, please follow:

$string = null;
$seconds = strtotime($string);    // change string into seconds
date = getdate($seconds);        // change seconds into a date
$computedDate = $date['mday'] . ' ' . $date['month'] . ', ' . $date ['year'] . ' : ' .$date['weekday'];
echo($computedDate);    // show date

Thus, null is Wednesday.

Now, why is this wrong?

Cheers,

tedd

_____________________
tedd@xxxxxxxxxxxx
http://sperling.com







--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


That's just it -- it's not wrong -- it's just local

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux