Here's a real puzzler:
strtotime('10-31-2007')
Returns 12-28-2017
BUT
strtotime('10/31/2007')
or
strtotime('2007-10-31')
Works fine................It's crap like this that leads to baldness
Btw, here's a quick fix:
$WorkDate = str_replace("-", "/", $PostDate);
You guys getting DOS'd, cause it's sure slow............
z
strtotime Weirdness
Moderator: General Moderators
Really..
I get this:
And nope, not geting dosd
I get this:
Code: Select all
C:\Users\scott>php -r "$t = strtotime('10-31-2007'); echo date('n-d-Y', $t);"
12-31-1969Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- Josh1billion
- Forum Contributor
- Posts: 316
- Joined: Tue Sep 11, 2007 3:25 pm
Version 5.2.4
I wouldn't say it's a bug. The function is a bit iffy itself, trying to parse "about any english textual date description" into a timestamp.
It can't be right all the time, although seemingly month-day-year should be an easy enough time to recognize.
A more common format (for those outside of the US) is day-month-year, and it seems PHP recognizes that.
So I believe in 10-31-2007 it's trying to parse it as day-month-year.
I wouldn't say it's a bug. The function is a bit iffy itself, trying to parse "about any english textual date description" into a timestamp.
It can't be right all the time, although seemingly month-day-year should be an easy enough time to recognize.
A more common format (for those outside of the US) is day-month-year, and it seems PHP recognizes that.
Code: Select all
C:\Users\scott>php -r "$t = strtotime('31-10-2007'); echo date('n-d-Y', $t);"
10-31-2007Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
That is strange.
More about the slowdown
Nah we're just a bunch of cheap skatesYou guys getting DOS'd, cause it's sure slow............
Re: strtotime Weirdness
agreed scottayy,
(in PHP Version 5.2.4)
"strtotime('10-31-2007')" returned "false"
"1/2/2007" seems to be parsed as the rubbish US style
"1-2-2007" seems to be parsed as the rubbish UK style
we should all just suggest/encourage/force users use the nice unambiguous sorting-for-free ISO style "Y-m-d".
(in PHP Version 5.2.4)
"strtotime('10-31-2007')" returned "false"
"1/2/2007" seems to be parsed as the rubbish US style
"1-2-2007" seems to be parsed as the rubbish UK style
we should all just suggest/encourage/force users use the nice unambiguous sorting-for-free ISO style "Y-m-d".