From: Kevin Kinsey on
Colin Guthrie wrote:
>
> For example, I discovered that some words (or strings beginning with
> those words) will return false positives:
>
> e.g.:
>
> [colin(a)jimmy Search (working)]$ php -r 'var_dump(strtotime("east"));'
> int(1270514111)
> [colin(a)jimmy Search (working)]$ php -r 'var_dump(strtotime("west"));'
> int(1270488914)
> [colin(a)jimmy Search (working)]$ php -r 'var_dump(strtotime("now"));'
> int(1270488928)
>
>
> The last one is valid! But the other two appear to do much the same thing...
>
> Can anyone think of why this would be valid results before I report this
> to the relevant authorities?

Time Zones?

[11] Mon 05.Apr.2010 13:05:41 [admin(a)archangel][~]
php -r "echo date('r',strtotime('now'));"
Mon, 05 Apr 2010 13:05:47 -0500

This is correct for my timezone (US Central Daylight Time).

[12] Mon 05.Apr.2010 13:05:47 [admin(a)archangel][~]
php -r "echo date('r',strtotime('east'));"
Mon, 05 Apr 2010 14:05:51 -0500

This is correct for the time zone east of me, US Eastern Daylight Time.
However, the TZ offset is wrong for that TZ, it's still mine.

[13] Mon 05.Apr.2010 13:05:51
[kadmin(a)archangel][~]
php -r "echo date('r',strtotime('west'));"
Mon, 05 Apr 2010 07:05:59 -0500

This is correct for American Samoa, but I've no idea why :-D

Nonetheless, I'm suspecting the programmers had something
like this in mind. Isn't strtotime() based on some GNU utility?

Kevin Kinsey
From: Kevin Kinsey on
Colin Guthrie wrote:
> 'Twas brillig, and Kevin Kinsey at 05/04/10 19:15 did gyre and gimble:
>> Nonetheless, I'm suspecting the programmers had something
>> like this in mind.
>
> Yeah I guess that's why it interprets these terms. Good thinking :)
>
>> Isn't strtotime() based on some GNU utility?
>
> Yeah, that's why I said "the relevant authorities". I couldn't remember
> off-hand where it came from so figured I'd not blame "PHP" just yet :p

Apparently these strings are being recognized as TZ stamps, but the underlying
logic is "not fully implemented": see
http://www.gnu.org/s/libc/manual/html_node/Low_002dLevel-Time-String-Parsing.html

Try it with some TZ stamps ... I'm pretty sure that in the previous
example it was taking "East" to be "EST", as I observed (rather by
accident) earlier.

Kevin Kinsey