Bug #15115 Updated: strtotime not recognizing 'Sa' as Saturday

From: Date: Tue, 22 Jan 2002 23:39:38 +0000
Subject: Bug #15115 Updated: strtotime not recognizing 'Sa' as Saturday
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-77841@lists.php.net to get a copy of this message
ID: 15115 Comment by: tim@x-session.dynodns.net Reported By: tim@x-session.dynodns.net Status: Open Bug Type: Date/time related Operating System: Win2000 Server PHP Version: 4.1.1 New Comment: Today I looked into the sourcecode of the strtotime function and found out that you only search for 3-character abbreviations. I think it's impossible to search for 2-character abbreviations because they wouldn't be unique... I think this solution also works fine for me: <? $dheader="Sa, 19 Jan 2002 12:28:51 -1100"; echo strtotime(ltrim(substr($dheader,-strlen($dbheader)+4))); // prints '1011482931' ?> I just cut away the 2- or 3-character abbreviation and the comma, then I cut away the remaining whitespace at the beginning of the string (if one exists...but it's not necessary to cut it away) and then I do the conversion. That should work fine for every 'Date:' header. Previous Comments: ------------------------------------------------------------------------ [2002-01-19 12:24:05] tim@x-session.dynodns.net What I do is parsing Mail-Headers, especially the 'Date:' header. One mail I parsed had the following 'Date:' header: Date: Sa, 19 Jan 2002 12:28:51 -1100 strtotime just returns -1 after parsing this string: <? $dheader="Sa, 19 Jan 2002 12:28:51 -1100"; echo strtotime($dheader); // prints '-1' ?> when I replace 'Sa' with 'Sat', it returns the correct value: <? $dheader="Sat, 19 Jan 2002 12:28:51 -1100"; echo strtotime($dheader); // prints '1011482931' ?> I am in Timezone GMT+1. Now should I find a workaround to this problem by replacing 'Sa' with 'Sat' for myself (so this is a mailer-problem) or perhaps you should consider this in your implementation (I don't know how often this 'Sa'/'Sat' problem occurs. ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=15115&edit=1

« previous php.dev (#77841) next »