You are here: Re: All Monday's & Thursdays « All PHP « IT news, forums, messages
Re: All Monday's & Thursdays

Posted by Janwillem Borleffs on 10/10/70 11:51

Stuart Colman wrote:
> I need to display every Monday and Thursday, and their relevant dates
> for a given month.
>
> I have looked at a few things, but not really got past being able to
> show one Monday or Thursday.
>
> Any ideas or pointers?
>

function getMonThuForMonth($month, $year = 0) {
// Day array
$dates = array();

// set the year
if (!$year) $year = date('Y');

// verify the month
if ($month < 1 || $month > 12) return false;

// first: get initial timestamp
$ts = mktime(0, 0, 0, $month, 1, $year);

// get all timestamps related to the Mondays
// and Thursdays of the month
while ($month == date('m', $ts)) {
if ('Mon' == date('D', $ts)) {
$dates[] = $ts;
}

$day = date('D', $ts = strtotime('thursday', $ts));
if ($month == date('m', $ts)) {
$dates[] = $ts;
}

$ts = strtotime('next monday', $ts);
}
return $dates;
}

$dates = getMonThuForMonth(6);
foreach ($dates as $date) {
echo date('Y M D (d)', $date), '<br />';
}


JW

 

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

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