|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-01-24 13:35 UTC] basil dot hussain at kodakweddings dot com
PHP does not correctly parse ordinal date suffixes in the strtotime() function. For example:
<?php
echo strtotime("10th August 2002");
echo strtotime("22nd January 1998");
echo strtotime("November 3rd 1980");
?>
They will all fail, returning -1.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 20:00:01 2025 UTC |
Could someone sanity check this patch? diff -c -r1.29 parsedate.y *** parsedate.y 2 Dec 2001 11:35:28 -0000 1.29 --- parsedate.y 24 Jan 2002 19:14:52 -0000 *************** *** 721,726 **** --- 721,740 ---- int i; int abbrev; + /* Strip ordinal suffixes from dates */ + if ((strlen (buff) == 3 || strlen (buff) == 4) && ISDIGIT(buff[0])) { + i = strlen (buff) - 2; + if (buff[i] == 's' && buff[i+1] == 't') { + buff[i] = '\0'; + } else if (buff[i] == 'n' && buff[i+1] == 'd') { + buff[i] = '\0'; + } else if (buff[i] == 'r' && buff[i+1] == 'd') { + buff[i] = '\0'; + } else if (buff[i] == 't' && buff[i+1] == 'h') { + buff[i] = '\0'; + } + } + /* Make it lowercase. */ for (p = buff; *p; p++) if (ISUPPER ((unsigned char) *p))