You are here: Re: php calendar to generate checkboxes next to each date « PHP Programming Language « IT news, forums, messages
Re: php calendar to generate checkboxes next to each date

Posted by NC on 11/19/63 11:45

Kentor wrote:
>
> NC: how would i display this for 12 months ahead, starting from the
> current date? and have it all sorted by months only showing the date
> number and the month as a header for each month, and then a big
> year header for the 2 years that would appear?

$timestamp = time();
$cutoff = strtotime(date('Y-m-d 23:59:59', $timestamp) . ' + 1 year');
// you could use $cutoff = $timestamp + 365*24*60*60,
// but it ignores leap year...
$year = date('Y', $timestamp);
$month = date('m', $timestamp);
$month_text = date('F', $timestamp);
echo "<h1>$year</h1>\r\n";
echo "<h2>$month_text</h2>\r\n<p>";
while ($timestamp <= $cutoff) {
if ($year <> date('Y', $timestamp)) {
$year = date('Y', $timestamp);
echo "<h1>$year</h1>\r\n";
}
if ($month <> date('m', $timestamp)) {
$month = date('m', $timestamp);
$month_text = date('F', $timestamp);
echo "<h2>$month_text</h2><p>\r\n";
}
$day = date('j', $timestamp);
$dateYMD = date('Y-m-d', $timestamp);
echo "<input type='checkbox' name='dates[]' ",
"value='$dateYMD'>$day \r\n";
$timestamp = $timestamp + 24*60*60;
}

Cheers,
NC

 

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

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