<?php
$now = date ( "g-i-s-n-j-Y" );
list( $hour , $minute , $second , $month , $date , $yearbefore )= explode ( "-" , $now );
$zonefile = file ( "templates/timezone" );
$timezone = $zonefile [ 0 ];
$now = date ( "l-d-F-Y-n" , mktime (( $hour + $timezone ), $minute , $second , $month , $date , $yearbefore ));
list( $day , $date , $month , $yearafter , $monthdigit )= explode ( "-" , $now );
$first = date ( "w-t" , mktime (( 0 + $timezone ), 0 , 0 , $monthdigit , 1 , $yearbefore ));
list( $firstday , $sumofdays )= explode ( "-" , $first );
$lastday = date ( "w" , mktime (( 0 + $timezone ), 0 , 0 , $monthdigit , $sumofdays , $yearbefore ));
if( $firstday ){
$sunday = 1 +( 7 - $firstday );
if( $sunday == 7 ) $sunday = 0 ;
} else {
$sunday = 1 ;
}
$sumofdaysbefore = date ( "t" , mktime (( 0 + $timezone ), 0 , 0 ,( $monthdigit - 1 ), 1 , $yearbefore ));
for( $i = 0 ; $i < $firstday ; $i ++){
$datelist [ $i ]= $sumofdaysbefore - $firstday + $i + 1 ;
$colorlist [ $i ]= "C0C0C0" ;
}
for( $i = $firstday , $d = 1 ; $d <= $sumofdays ; $i ++, $d ++){
$datelist [ $i ]= $d ;
if(( $d % 7 )== $sunday ) { $colorlist [ $i ]= "FF0000" ; }
else { $colorlist [ $i ]= "000000" ; }
if( $d == $date ) $colorlist [ $i ]= "00BB00" ;
}
$sumofdatenow = sizeof ( $datelist );
for( $i = $sumofdatenow , $s = 0 ; $s <( 6 - $lastday ); $i ++, $s ++){
$datelist [ $i ]= $s + 1 ;
$colorlist [ $i ]= "C0C0C0" ;
}
$week = file ( "templates/week.htm" );
for( $i = 0 ; $i < sizeof ( $week ); $i ++){
$cldrlist .= $week [ $i ];
}
$sumofweek = sizeof ( $datelist )/ 7 ;
for( $i = 0 ; $i < $sumofweek ; $i ++){
$idx = $i * 7 ;
$idx1 = $idx + 1 ;
$idx2 = $idx + 2 ;
$idx3 = $idx + 3 ;
$idx4 = $idx + 4 ;
$idx5 = $idx + 5 ;
$idx6 = $idx + 6 ;
$weeklist = $cldrlist ;
$weeklist = ereg_replace ( "1X" , "$datelist[$idx]" , $weeklist );
$weeklist = ereg_replace ( "1COLOR" , $colorlist [ $idx ], $weeklist );
$weeklist = ereg_replace ( "2X" , "$datelist[$idx1]" , $weeklist );
$weeklist = ereg_replace ( "2COLOR" , $colorlist [ $idx + 1 ], $weeklist );
$weeklist = ereg_replace ( "3X" , "$datelist[$idx2]" , $weeklist );
$weeklist = ereg_replace ( "3COLOR" , $colorlist [ $idx + 2 ], $weeklist );
$weeklist = ereg_replace ( "4X" , "$datelist[$idx3]" , $weeklist );
$weeklist = ereg_replace ( "4COLOR" , $colorlist [ $idx + 3 ], $weeklist );
$weeklist = ereg_replace ( "5X" , "$datelist[$idx4]" , $weeklist );
$weeklist = ereg_replace ( "5COLOR" , $colorlist [ $idx + 4 ], $weeklist );
$weeklist = ereg_replace ( "6X" , "$datelist[$idx5]" , $weeklist );
$weeklist = ereg_replace ( "6COLOR" , $colorlist [ $idx + 5 ], $weeklist );
$weeklist = ereg_replace ( "7X" , "$datelist[$idx6]" , $weeklist );
$weeklist = ereg_replace ( "7COLOR" , $colorlist [ $idx + 6 ], $weeklist );
$calendar .= $weeklist ;
}
$template = file ( "templates/calendar.htm" );
for( $i = 0 ; $i < sizeof ( $template ); $i ++){
$line = $template [ $i ];
$line = ereg_replace ( "DAY" , $day , $line );
$line = ereg_replace ( "DATE" , $date , $line );
$line = ereg_replace ( "MONTH" , $month , $line );
$line = ereg_replace ( "YEAR" , $yearafter , $line );
$line = ereg_replace ( "<!--LIST OF CALENDAR-->" , $calendar , $line );
echo $line ;
}
?>
these are the template files :
calendar.htm
<p align="center"><font size="2" face="helvetica, arial, verdana"color="#FFFFFF">DAY<br>
</font><b><font size="6" color="#FF0000" face="helvetica, arial,verdana">DATE</font><font size="6"><br>
</font></b><font color="#FFFFFF" face="helvetica, arial, verdana"><fontsize="2">MONTH, YEAR</font></font></p>
<table border="1" width="20%" cellspacing="0" cellpadding="0" bordercolor="#808080"align="center">
<tr>
<td width="100%">
<table border="0" width="100%" bgcolor="#808080" cellspacing="0"cellpadding="0">
<tr>
<td width="100%">
<p align="center"><b><font size="2" face="arial, helvetica, verdana"color="#FF0000"><</font><font size="2" face="arial, helvetica, verdana" color="#FFFFFF"> MONTH</font><font size="2" face="arial, helvetica, verdana" color="#FF0000"> ></font></b></p>
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" colspan="7" bgcolor="#FFFFFF">
<p align="center"><b><font size="2" face="arial, helvetica, verdana"color="#FF0000"><</font><font size="2" face="arial, helvetica, verdana" color="#000000"> YEAR</font><font size="2" face="arial, helvetica, verdana" color="#FF0000"> ></font></b></td>
</tr>
<tr>
<td width="15%" bgcolor="#FFFFFF">
<p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#AA0000">S</font></b></td>
<td width="14%" bgcolor="#FFFFFF">
<p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#0000FF">M</font></b></td>
<td width="14%" bgcolor="#FFFFFF">
<p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#0000FF">T</font></b></td>
<td width="14%" bgcolor="#FFFFFF">
<p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#0000FF">W</font></b></td>
<td width="14%" bgcolor="#FFFFFF">
<p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#0000FF">T</font></b></td>
<td width="14%" bgcolor="#FFFFFF">
<p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#0000FF">F</font></b></td>
<td width="15%" bgcolor="#FFFFFF">
<p align="center"><b><font size="1" face="helvetica, arial, verdana"color="#0000FF">S</font></b></td>
</tr>
<!--LIST OF CALENDAR-->
</table>
</td>
</tr>
</table>
week.htm
<tr>
<td width="14%" bgcolor="#FFFFFF">
<p align="center"><b><font color="#1COLOR" size="1" face="helvetica,arial, verdana">1X</font></b></td>
<td width="14%" bgcolor="#FFFFFF">
<p align="center"><b><font color="#2COLOR" size="1" face="helvetica,arial, verdana">2X</font></b></td>
<td width="14%" bgcolor="#FFFFFF">
<p align="center"><b><font color="#3COLOR" size="1" face="helvetica,arial, verdana">3X</font></b></td>
<td width="14%" bgcolor="#FFFFFF">
<p align="center"><b><font color="#4COLOR" size="1" face="helvetica,arial, verdana">4X</font></b></td>
<td width="14%" bgcolor="#FFFFFF">
<p align="center"><b><font color="#5COLOR" size="1" face="helvetica,arial, verdana">5X</font></b></td>
<td width="15%" bgcolor="#FFFFFF">
<p align="center"><b><font color="#6COLOR" size="1" face="helvetica,arial, verdana">6X</font></b></td>
<td width="15%" bgcolor="#FFFFFF">
<p align="center"><b><font color="#7COLOR" size="1" face="helvetica,arial, verdana">7X</font></b></td>
</tr>
timezone
file timezone contains time difference (hour) in one line
example : my server is in USA and i am in Indonesia
time difference between USA and Indonesia is 7 hours
so file timezone contains one line that is "7" (without quote)
Simple PHP control CSS Calendar Categories : PHP , HTML and PHP , Calendar , Date Time , CSS Customizable Calendar Class Categories : HTML and PHP , Date Time , PHP , PHP Classes , Calendar This script contains 2 functions: 1 to create html select object based on your own customer date format entry- "M d Y h:i.... etc". The second function processes the select object on submit back to unix time. Categories : PHP , Calendar , Date Time , HTML and PHP CALENDAR - easy calendar-navigation with PHP Categories : PHP , Date Time , HTML and PHP , Calendar Count how many weeks in the month have a specified day, such as Mon, Tue, etc. Var avail - number of days - first day name of the month, occurrences of Sun, occurrences of Mon, etc. Allows you to calculate number of working hours exclude Holidays. Categories : Calendar , Date Time , PHP , Databases , MySQL Local-to-user date and time display regardless of time zone or where the website's server is located Categories : PHP , Date Time , HTML and PHP , Java Script Dynamic Calendar in PHP, Javascript and HTML. Categories : PHP , Java Script , HTML and PHP , Calendar Convert date's in YYYY-MM-DD (i.e. mysql format) into PHP3 timestamps. Also Find the difference in days between two PHP3 timestamps. Categories : HTML and PHP , PHP , MySQL , Date Time php html calendar dynamic Categories : HTML and PHP , PHP , Calendar Creates three SELECT form fields: Month, Day, and Year. You give it a string which will be used to make the name for the three fields, and a number of seconds to use as the default date. If you give it blank for this value, the current date is used. Categories : HTML and PHP , PHP , Date Time If you want to create select buttons featuring current date this example will show you how... Categories : Date Time , HTML and PHP , PHP Shows the current time as a PNG-image. This script does not use the GD
library. You can use it as a benchmark (because it's slow), or as a quick
reference for implementing a simple PNG-file generator. Categories : Graphics , Zlib , Calendar , PHP , Date Time table calendar pretty much does what cal(1) does - prints out a calendar.
Categories : Date Time , PHP , Calendar A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function. Categories : PHP , PHP Classes , Calendar , Date Time pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP , Date Time , Calendar , PHP Classes