 |
| Hinweise |
Willkommen im TP-Hilfe-Forum!Dies ist ein Forum zu den Themen Photoshop, Dreamweaver, Flash, Selbständigkeit und mehr, in dem Du Hilfe, Anleitung oder eine Lösung zu Deinen Problemen erhältst. Aktuell bist Du in unseren Foren als Gast mit reinen Leserechten unterwegs. Wenn Du Dich registrierst, kannst Du eigene Themen verfassen, Deine Frage stellen und privat mit anderen TPlern kommunizieren. Weitere Foren werden zugänglich, und Du wirst – falls gewünscht – per Mail über neue Beiträge informiert. Die Registrierung ist schnell und kostenlos. Sollten bei der Registrierung Fragen auftauchen, reicht ein Klick in unsere Hilfe - Häufig gestellte Fragen oder eine kurze Mitteilung an das Support-Team. Viel Spaß bei Traum-Projekt.com |
13.05.2005, 22:48
|
#1
|
|
TP-Insider
Registriert seit: Jul 2003
Ort: München
|
Nanu, Kalender rechnet "nur" den Mai falsch?
Mir ist gerade aufgefallen, dass mein Kalender plötzlich falsch geht. Switch ich aber einen Monat vor oder zurück, stimmen die Daten wieder? Steh auf dem Schlauch :/
http://newlevel.de/calendar2.php
PHP-Code:
<?php
$calendar_language = "ger"; //The extension of the calendar language file.
$table_border = 0; //The border of the table
$table_cellspacing = 1; //Cellspacing of the table
$table_cellpadding = 2; //Cellpadding of the table
$table_width = '180px'; //Table width in pixels or %'s
$table_height = '160px';
$language_file = "calendar." . $calendar_language; //Language file into variable
$fd = fopen( $language_file, "r" ); //Open the language file
$fd = fread( $fd, filesize( $language_file ) ); //Read the opened file
$language_array = explode( "\n" , $fd ); //Put file info into array
$dayname = array_slice($language_array,0,7); //The names of the days
$monthname = array_slice($language_array,7); //The rest of the language file are the monthnames
//
/////////////////////////////////////////////
/////////////////////////////////////////////
//Use the date to build up the calendar. From the Query_string or the current date
//
if( isset( $_GET['date'] ) )
list($month,$year) = explode("-",$_GET['date']);
else
{
$month = date("m");
$year = date("Y");
}
//
/////////////////////////////////////////////
$date_string = mktime(0,0,0,$month,1,$year); //The date string we need for some info... saves space ^_^
$day_start = date("w",$date_string)-1; //The number of the 1st day of the week
/////////////////////////////////////////////
//Filter the current $_GET['date'] from the QUERY_STRING
//
$QUERY_STRING = ereg_replace("&date=".$month."-".$year,"",$_SERVER['QUERY_STRING']);
//
/////////////////////////////////////////////
/////////////////////////////////////////////
//Calculate the previous/next month/year
//
if( $month < 12 )
{
$next_month = $month+1;
$next_date = $next_month."-".$year;
}
else
{
$next_year = $year+1;
$next_date = "1-".$next_year;
$next_month = 1;
}
if( $month > 1 )
{
$previous_month = $month-1;
$next_month = $month+1;
$previous_date = $previous_month."-".$year;
}
else
{
$previous_year = $year-1;
$previous_date = "12-".$previous_year;
$previous_month = 12;
}
//
/////////////////////////////////////////////
// darussol: DEFINITION OF THETRANSLATED MONTH+YEAR TO BE USED IN THE TABLE AND INFO-TITLES (18 May 2004)
// e-man : USING THE VALUES OF THE PREVIOUS AND NEXT MONTH FOR THE TITLE DAY (19 May 2004);
$table_caption = $monthname[date("n",$date_string)-1] . " " . $year; // current
/////////////////////////////////////////////
//Print the calendar table header
//
echo "
<table border=\"" . $table_border . "\" cellpadding=\"" . $table_cellpadding . "\" cellspacing=\"" . $table_cellspacing . "\" style=\"height:" . $table_height . "\" width=\"" . $table_width . "\">
<tr>
<td align=\"center\" class=\"cal_head\"><a class=\"cal_head\" href=\"" . $_SERVER['PHP_SELF'] . "?" . $QUERY_STRING . "&date=" .
$previous_date . "\" title=\"" . $table_caption_prev . "\">«</a></td>
<td align=\"center\" class=\"cal_head\" colspan=\"5\">" . $table_caption . "</td>
<td align=\"center\" class=\"cal_head\"><a class=\"cal_head\" href=\"" . $_SERVER['PHP_SELF'] . "?" . $QUERY_STRING . "&date=" .
$next_date . "\" title=\"" . $table_caption_foll . "\">»</a></td>
</tr>
<tr>
<td class=\"cal_days\">".$dayname[0]."</td>
<td class=\"cal_days\">".$dayname[1]."</td>
<td class=\"cal_days\">".$dayname[2]."</td>
<td class=\"cal_days\">".$dayname[3]."</td>
<td class=\"cal_days\">".$dayname[4]."</td>
<td class=\"cal_days\">".$dayname[5]."</td>
<td class=\"cal_days\">".$dayname[6]."</td>
</tr><tr>
";
//
/////////////////////////////////////////////
/////////////////////////////////////////////
//The empty columns before the 1st day of the week
//
for( $i = 0 ; $i < $day_start; $i++ )
{
echo "<td class=\"cal_content\"> </td>";
}
//
/////////////////////////////////////////////
$current_position = $day_start; //The current (column) position of the current day from the loop
$total_days_in_month = date("t",$date_string); //The total days in the month for the end of the loop
/////////////////////////////////////////////
//Loop all the days from the month
//
for( $i = 1; $i <= $total_days_in_month ; $i++)
{
$class = "cal_content";
if( $i == date("j") && $month == date("n") && $year == date("Y") )
$class = "cal_today";
$current_position++;
/* for the event filter */
/* e-man : added 07 June 04 */
$date_stamp = $year."-".$month."-".sprintf( "%02d",$i);
echo "<td align=\"center\" class=\"" . $class . "\">" . $link_start . $i . $link_end . "</td>";
if($day_start==-1 && $current_position == 6 && $i<=7){
echo "</tr><tr>\n";
$current_position = 0;
}
if( $current_position == 7)
{
echo "</tr><tr>\n";
$current_position = 0;
}
}
//
/////////////////////////////////////////////
$end_day = 7-$current_position; //There are
/////////////////////////////////////////////
//Fill the last columns
//
for( $i = 0 ; $i < $end_day ; $i++ )
echo "<td class=\"cal_content\"></td>\n";
//
/////////////////////////////////////////////
echo "</tr></table>"; // Close the table
?>
__________________
Spitzen Hoster: All-Inkl
|
|
|
13.05.2005, 22:56
|
#2
|
|
TP-Special Mod
Registriert seit: Feb 2005
Ort: Haan / NRW
|
was geht denn falsch ?
lass Dir doch mal $month und $year ausgeben
|
|
|
14.05.2005, 09:15
|
#3
|
|
TP-Insider
Registriert seit: Jul 2003
Ort: München
|
Der Monat Mai fängt am Montag den 1. an, der 1. war aber ein Sonntag. Komisch ist, dass die Monate davor und danach stimmen, das macht mit Kopfschmerzen: :/
__________________
Spitzen Hoster: All-Inkl
|
|
|
14.05.2005, 13:06
|
#5
|
|
TP-Special Mod
Registriert seit: Feb 2005
Ort: Haan / NRW
|
Dank codethief wars leicht aufzuspüren.
Folgende Modifikation:
$day_start = date("w",$date_string)-1; //The number of the 1st day of the week
if($day_start<0) $day_start=6;
Bei Sonntag(0) wurde einfach 1 abgezogen und 0-1 = -1 statt 6 
|
|
|
14.05.2005, 20:35
|
#6
|
|
TP-Insider
Registriert seit: Jul 2003
Ort: München
|
Super, Vielen Dank !
__________________
Spitzen Hoster: All-Inkl
|
|
|
|
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
|
|
|
| Themen-Optionen |
Thema durchsuchen |
|
|
|
| Thema bewerten |
|
|
Forumregeln
|
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.
HTML-Code ist aus.
|
|
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:27 Uhr.
|
 |