It seems different php versions have different outputs for this code:
Fedora Core 14 (x86):
first: 01-03-2011 00:00:00
second: 08-03-2011 00:00:00
third: 22-03-2011 00:00:00
fourth: 22-03-2011 00:00:00
fifth: 29-03-2011 00:00:00
Fedora Core11 (x86_64):
first: 31-12-1969 16:00:00
second: 31-12-1969 16:00:00
third: 22-03-2011 00:00:00
fourth: 31-12-1969 16:00:00
fifth: 31-12-1969 16:00:00
However it works if reorder Year and Month like:
echo first: .date(d-m-Y H:i:s,strtotime('2011 March first
wednesday')).\n;
echo second: .date(d-m-Y H:i:s,strtotime('2011 March second
wednesday')).\n;
echo third: .date(d-m-Y H:i:s,strtotime('2011 March third
wednesday')).\n;
echo fourth: .date(d-m-Y H:i:s,strtotime('2011 March fourth
wednesday')).\n;
echo fifth: .date(d-m-Y H:i:s,strtotime('2011 March fifth
wednesday')).\n;
first: 02-03-2011 00:00:00
second: 09-03-2011 00:00:00
third: 16-03-2011 00:00:00
fourth: 23-03-2011 00:00:00
fifth: 30-03-2011 00:00:00
Thanks
-dani
On Sat, Apr 2, 2011 at 1:17 AM, Louis Huppenbauer
louis.huppenba...@gmail.com wrote:
Just try of March. Worked for me.
print first: .date(d-m-Y H:i:s,strtotime('first Tuesday of March
2011')).\n;
print second: .date(d-m-Y H:i:s,strtotime('second Tuesday of March
2011')).\n;
print third: .date(d-m-Y H:i:s,strtotime('third Tuesday of March
2011')).\n;
print fourth: .date(d-m-Y H:i:s,strtotime('fourth Tuesday of March
2011')).\n;
print fifth: .date(d-m-Y H:i:s,strtotime('fifth Tuesday of March
2011')).\n;
2011/4/2 Dan Dan dani.mani...@gmail.com:
I removed the day (1 before the March), but its still giving the same
result, i.e. different days of month with and without the 'first'. Any
further help ?
print first Tuesday :.date(d-m-Y H:i:s,strtotime('March 2011
Tuesday')).\n;
print first: .date(d-m-Y H:i:s,strtotime('March 2011 first
Tuesday')).\n;
print second: .date(d-m-Y H:i:s,strtotime('March 2011 second
Tuesday')).\n;
print third: .date(d-m-Y H:i:s,strtotime('March 2011 third
Tuesday')).\n;
print fourth: .date(d-m-Y H:i:s,strtotime('March 2011 fourth
Tuesday')).\n;
first Tuesday :01-03-2011 00:00:00
first: 08-03-2011 00:00:00
second: 15-03-2011 00:00:00
third: 22-03-2011 00:00:00
fourth: 29-03-2011 00:00:00
Thanks
-dani
On Fri, Apr 1, 2011 at 9:37 AM, Daniel Brown danbr...@php.net wrote:
On Fri, Apr 1, 2011 at 12:35, Dan Dan dani.mani...@gmail.com wrote:
Hi Folks,
I am trying to get the day of month for a particular day of week (e.g.
Tuesday) for the first, second, third, fourth week in a month. The
code i
have seems issues in March, but works e.g. in April:
print date(d-m-Y H:i:s,strtotime('1 March 2011 Tuesday'));
01-03-2011 00:00:00
print date(d-m-Y H:i:s,strtotime('1 March 2011 first Tuesday'));
08-03-2011 00:00:00
While in April, I have
print date(d-m-Y H:i:s,strtotime('1 April 2011 Tuesday'));
05-04-2011 00:00:00
print date(d-m-Y H:i:s,strtotime('1 April 2011 first Tuesday'));
05-04-2011 00:00:00
Could someone help whats wrong with the technique i am trying to find
that
day of month. Is there any better way ?
Because you're combining the date with the day of the week. It so
happens that 1 March was a Tuesday, but today - 1 April - is a Friday.
Pick one or the other, not both.
--
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/