|
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]
|