php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15115 strtotime not recognizing 'Sa' as Saturday
Submitted: 2002-01-19 12:24 UTC Modified: 2002-05-25 06:32 UTC
From: tim at x-session dot dynodns dot net Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.1.1 OS: Win2000 Server
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tim at x-session dot dynodns dot net
New email:
PHP Version: OS:

 

 [2002-01-19 12:24 UTC] tim at x-session dot dynodns dot 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-22 18:39 UTC] tim at x-session dot dynodns dot net
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.
 [2002-05-25 06:32 UTC] derick@php.net
Not a bug in PHP, 'Sa' is not supposed to work. It's clearly a bug in the mailer.

Derick
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 13:01:28 2025 UTC