Reply to Re: This Monday problem

Your name:

Reply:


Posted by Adam on 03/22/07 14:04

On Thu, 22 Mar 2007 14:47:56 +0100, J.O. Aho wrote:

Wow! After a *long* break from this group, i'd forgotten how lightning
fast people here are ;-) Good to be back!

>> I need to be able to return the corresponding dates for Mondays - and
>> have tried various functions, scripts with varying degrees of success.
>> date('d-M-Y', strtotime('this monday'));
>>
>> ... works, as does:
>>
>> date('d-M-Y', strtotime('last monday'));
>>
>> However, whilst this function works well most of the time, for some
>> reason it pukes on Monday 19th March - and always returns 18th Mar
>> (which is a Sunday!).

>Sure you haven't set the year to 2002 or 2013?

Nope - I'm not playing with the year in any way.

>Does "date('d-M-Y', strtotime('last monday')+1);" make any difference?

Yes. The only way I could kludge it was to use:

date('d-M-Y', strtotime('last monday')+7)

- which gave the correct date (Mon 12th + 7 = Mon 19th). It was "this
monday" that was returning the wrong date.

I tried a function - getMondays($year) - as grabbed from the php.net
online manual hints and that one fails on that same Monday as well -
though it uses a mktime approach.

>> I could understand it if it crossed a leap year threshold of some sort
>> (eg. Feb 28th) - but 18 March???
>> This is with both PHP4 and PHP5.

>What system does the php run on?

Local servers on WinXP and Ubuntu - remote is on Unix. Same problem on
all three systems.

Weird!

Adam.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация