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