You are here: Re: Looking for a date function : "First Monday after a certain date" « PHP Programming Language « IT news, forums, messages
Re: Looking for a date function : "First Monday after a certain date"

Posted by Emmanuel Ayrault on 07/31/05 18:35

Martien van Wanrooij a écrit :

> So I decided to create two fields firstdisplaytime and lastdisplaytime and I
> made a webform where the staff can update the scheduling. Up to now
> firstdisplaytime and lastdisplaytime are updated manually but I would like
> to write such a code that both fields are calculated automatically (monday
> before and after the celebrations) unless these dates are filled in
> explicitely by the staff.
> Additional suggestions will be welcome, thanks anyway.
>

I'm afraid I don't understand all what you want to do. Could you give
some exemple with real dates of celebration and the period you want to
display them.

Otherwise, you can use strtotime to calculate the monday some weeks
before or after the current date:

<?php

echo 'Today: '.date('Y-m-d').'<br />';
echo date('Y-m-d',strtotime("-1 week last Monday")).'<br />';
echo date('Y-m-d',strtotime("last Monday")).'<br />';
echo date('Y-m-d',strtotime("Monday")).'<br />';
echo date('Y-m-d',strtotime("next Monday")).'<br />';
echo date('Y-m-d',strtotime("+1 week next Monday")).'<br />';
?>


After that, you just have to use a correct query in mysql to display the
dates you want to show between 2 limits.

Hope it can be useful.

--
Manu

 

Navigation:

[Reply to this 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

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