BuffaloHELP
Sep 30 2006, 10:33 AM
Original simple PHP calendar source hereI was looking for a simple PHP generated calendar. But I wanted to place detailed information to show on demand. And installing another database with separate management would have been too much of access codes and passwords to remember. And what if I want someone else to manage the calendar when I am not able? This is my version of using simple PHP calendar script to link to Yahoo! calendar. The twist is that figuring out how Yahoo! calendar selection worked. And then depending on which date was clicked it will bring up the appropriate date/week on Yahoo! calendar. First step was to understand the url. When checking the status bar I noticed //calendar.mail.yahoo.com/trap17.demo/?v=1&t=1157068800. The values of v as follows: v=0 : day view v=1 : week view v=2 : month view ...etc The values of t as follows: t values were assigned in total seconds in Unix Epoch time format starting from January 1, 1970. It took me about 8 hours to figure out how this worked. The logic I used was to figure out how to translate any given day number to unix seconds correctly. This will give an approximate time value for Yahoo! calendar to display correctly. CODE echo "<td bgcolor=#f2f2f2><a class='navigation' target='_blank' href='$yahoo/?v=0&t=$unixtime'> $day_num </a></td>\n"; This is the clickable link the script will generate using above values. CODE $clickdate = unixtojd(mktime(0,0,0,$month,$day_num,$year)) I found this code accidently that this will translate any $month, $day_num and $year set by the script. This was the hard part. Assign this to a variable. CODE $unixtime = jdtounix($clickdate); Once a desired date's unix time was located, it must be re-translated back to Unix Epoch time format. Note that when you just use unixtojd, it will return time value that does not match to the right number of digits. It's because Unix Epoch counts seconds from january 1, 1970. So let's say you want to find Unix Epoch of September 1, 2006, you have to figure out the total second difference between these two dates  Too much of work. But when unix time was found for julian date, you can then turn unix time to Unix Epoch value. CODE $yahoo = "http://calendar.mail.yahoo.com/trap17.demo"; To make my code user friendly, I have assigned the link to Yahoo! calendar as a variable. And the complete code goes like this. I modified from the original to insert a color CODE <?php //--my addition to Yahoo variables $yahoo = "http://calendar.mail.yahoo.com/trap17.demo";
//This gets today's date $date =time ();
//This puts the day, month, and year in seperate variables $day = date('d', $date); $month = date('m', $date); $year = date('Y', $date);
//Here we generate the first day of the month $first_day = mktime(0,0,0,$month, 1, $year);
//This gets us the month name $title = date('F', $first_day);
//Here we find out what day of the week the first day of the month falls on $day_of_week = date('D', $first_day);
//Once we know what day of the week it falls on, we know how many blank days occure before it. //If the first day of the week is a Sunday then it would be zero switch($day_of_week){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; }
//We then determine how many days are in the current month $days_in_month = cal_days_in_month(0, $month, $year);
//Here we start building the table heads echo "<table border=1 width=250>"; echo "<tr><th colspan=7> $title $year </th></tr>"; echo "<tr> <td width=35 align=center>S</td> <td width=35 align=center>M</td> <td width=35 align=center>T</td> <td width=35 align=center>W</td> <td width=35 align=center>T</td> <td width=35 align=center>F</td> <td width=35 align=center>S</td> </tr>";
//This counts the days in the week, up to 7 $day_count = 1;
echo "<tr>"; //first we take care of those blank days while ( $blank > 0 ) { echo "<td></td>\n"; $blank = $blank-1; $day_count++; }
//sets the first day of the month to 1 $day_num = 1;
//count up the days, untill we've done all of them in the month while ( $day_num <= $days_in_month ) {
//--my addition to Yahoo variables 2 $clickdate = unixtojd(mktime(0,0,0,$month,$day_num,$year)); $unixtime = jdtounix($clickdate);
echo "<td bgcolor=#f2f2f2><a class='navigation' target='_blank' href='$yahoo/?v=0&t=$unixtime'> $day_num </a></td>\n"; $day_num++; $day_count++;
//Make sure we start a new row every week if ($day_count > 7) { echo "</tr><tr>\n"; $day_count = 1; } }
//Finaly we finish out the table with some blank details if needed while ( $day_count >1 && $day_count <=7 ) { echo "<td> </td>"; $day_count++; }
echo "</tr></table>";
?> Since this is a simple table generating sequence, it will obey all your CSS template  Which is a very good thing. You can insert HREF class for the link. See the working model here calendarNext project modification idea - making hover effect to show different options, i.e. view in month/week/day. Give it a try...  **UPDATE** Looks like instead of translating and re-translating you can simply use CODE $unixtime = mktime(0,0,0,$month,$day_num,$year); now that I understand how mktime() works
Reply
jlhaslip
Sep 30 2006, 02:21 PM
BH, get out of my head... Been working on a calendar script all week wondering how to make it a web-based, accessible calendar for the schedule of the local Hockey association. Perfect timing for this Tutorial. I think I might have an idea or two to add some color to this thing. I will post them here when I come up with them.
Reply
BuffaloHELP
Sep 30 2006, 08:33 PM
Yes, the same unresulting searches lead me to develop this little trick myself. Looks like there aren't many sports related practical web scripts out there. Hummm... a possible opportunity to make on goods? And it wasn't that other PHP calendars weren't good enough. In fact EasyPHPCalendar was just super. But to use such over complexed script for few small sports leagues was not my intention. And to relate Yahoo! calendar (which what my teammates use anyway) already familiar with my team was the natural choice. Google calendar wasn't as easy as Yahoo! calendar to be utilized anyway. Yahoo! calendar also allows other Yahoo! users to add or modify one event calendar. This is useful when allowing multiple captains to have control over a season's league sessions. jlhaslip, how about highlighting days i.e., all Tuesdays, Tuesday thur Saturday or just the working days.**UPDATE** I have made few adjustments to highlight or make HREF link appear only for certain days of the week. The new addition to the code CODE $shadeday = date('D' , $unixtime);
if ($shadeday != "Sun" && $shadeday != "Mon" && $shadeday != "Sat") By adding this simple condition, I can let my CLASS to be used only Tuesday thru Friday. The modified code HTML <style type="text/css"> <!--@import url("css.css"); --> </style>
<body> Highlighting only certain days of the week<br /><br />
<?php //--my addition to Yahoo variables $yahoo = "http://calendar.mail.yahoo.com/trap17.demo";
//This gets today's date $date =time () ;
//This puts the day, month, and year in seperate variables $day = date('d', $date) ; $month = date('m', $date) ; $year = date('Y', $date) ;
//Here we generate the first day of the month $first_day = mktime(0,0,0,$month, 1, $year) ;
//This gets us the month name $title = date('F', $first_day) ;
//Here we find out what day of the week the first day of the month falls on $day_of_week = date('D', $first_day) ;
//Once we know what day of the week it falls on, we know how many blank days occure before it. //If the first day of the week is a Sunday then it would be zero switch($day_of_week){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; }
//We then determine how many days are in the current month $days_in_month = cal_days_in_month(0, $month, $year) ;
//Here we start building the table heads echo "<table border=1 width=250>"; echo "<tr><th colspan=7> $title $year </th></tr>"; echo "<tr> <td width=35 align=center>S</td> <td width=35 align=center>M</td> <td width=35 align=center>T</td> <td width=35 align=center>W</td> <td width=35 align=center>T</td> <td width=35 align=center>F</td> <td width=35 align=center>S</td> </tr>";
//This counts the days in the week, up to 7 $day_count = 1;
echo "<tr>"; //first we take care of those blank days while ( $blank > 0 ) { echo "<td></td>\n"; $blank = $blank-1; $day_count++; }
//sets the first day of the month to 1 $day_num = 1;
//count up the days, untill we've done all of them in the month while ( $day_num <= $days_in_month ) {
//--my addition to Yahoo variables 2 $unixtime = mktime(0,0,0,$month,$day_num,$year); $shadeday = date('D' , $unixtime);
if ($shadeday != "Sun" && $shadeday != "Mon" && $shadeday != "Sat") { echo "<td><a class='navigation' target='_blank' href='$yahoo/?v=0&t=$unixtime'> $day_num </a></td>\n"; } else { echo "<td> $day_num </td>\n"; } $day_num++; $day_count++;
//Make sure we start a new row every week if ($day_count > 7) { echo "</tr><tr>\n"; $day_count = 1; } }
//Finaly we finish out the table with some blank details if needed while ( $day_count >1 && $day_count <=7 ) { echo "<td> </td>"; $day_count++; }
echo "</tr></table>";
?>
</body> You can view the working script here
Reply
jlhaslip
Oct 1 2006, 12:29 AM
Oops. Just found one problem. Seems the date is tied to the server. It is 6:30 pm Mountain Daylight time on Sept 30th and when I clicked the calender demo link, it shows the October calender.
Reply
BuffaloHELP
Oct 1 2006, 12:41 AM
Hummm yes you're right. Is there a way to calculate viewer's time zone? Perhaps two options: 1) view in correct time zone according to a visitor 2) view in correct time zone according to event holder After making this post, a quick search revealed CODE bool date_default_timezone_set ( string timezone_identifier )
Lists of timezone_identifier http://www.php.net/manual/en/timezones.phpLet's see if I can use this. **UPDATE** Modifying the initial time value, I was able to offset the server time and my time zone difference. CODE //This gets today's date $date =time () + (60 * 60 * -4); This offsets -4 hours to reflect GMT-4. Since the value time() returns as Unix Epoch (in total seconds) I simply offset $date with 4 hours as units in seconds. The next step is to see if this can be done using viewer's individual time zone.
Reply
jlhaslip
Oct 1 2006, 04:35 AM
I have tested the time adjustment and it appears to work okay. It is set for gmt-4 right now. I added some css and an if/else to 'shade' the rows so each week is clearly defined. It still connects to your sample calendar. http://www.jlhaslip.trap17.com/cal_test/test_cal.php to run the demo. CODE <style type="text/css"> body { background-color: #dddddd; font: 0.85em Arial,Helvetica,Verdana, sans-serif, serif; min-height: 100%; margin-left:auto; margin-right:auto; text-align:center; } table, tr, td { margin-left:auto; margin-right:auto; text-align:center; }
a:link, a:visited { color: green; border-left: 5px solid #00ff00; font-weight: bold; display:block; } a:hover { background-color: #00dd66; color: #ffff00; border-left: 5px solid #ffff00; }
// use the classes odd and even for the colors of the shaded rows
.odd {background-color: #eeeeee; }
.even {background-color: #cccccc; }
</style>
<body> <h4>Highlighting only certain days of the week</br>And alternate shading of rows</h4>
<?php //--my addition to Yahoo variables $yahoo = "http://calendar.mail.yahoo.com/trap17.demo";
//This gets today's date $date =time () + (60 * 60 * -4);
//This puts the day, month, and year in seperate variables $day = date('d', $date) ; $month = date('m', $date) ; $year = date('Y', $date) ;
// use the row variable to switch shading on each line $row = 2;
//Here we generate the first day of the month $first_day = mktime(0,0,0,$month, 1, $year) ;
//This gets us the month name $title = date('F', $first_day) ;
//Here we find out what day of the week the first day of the month falls on $day_of_week = date('D', $first_day) ;
//Once we know what day of the week it falls on, we know how many blank days occure before it. //If the first day of the week is a Sunday then it would be zero switch($day_of_week){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; }
//We then determine how many days are in the current month $days_in_month = cal_days_in_month(0, $month, $year) ;
//Here we start building the table heads echo "<table border=1 width=250>"; echo "<tr class=\"even\"><th colspan=7> $title $year </th></tr>"; echo "<tr class=\"odd\"> <td width=35 align=center>S</td> <td width=35 align=center>M</td> <td width=35 align=center>T</td> <td width=35 align=center>W</td> <td width=35 align=center>T</td> <td width=35 align=center>F</td> <td width=35 align=center>S</td> </tr>";
//This counts the days in the week, up to 7 $day_count = 1;
echo "<tr class=\"even\">"; //first we take care of those blank days while ( $blank > 0 ) { echo "<td></td>\n"; $blank = $blank-1; $day_count++; }
//sets the first day of the month to 1 $day_num = 1;
//count up the days, untill we've done all of them in the month while ( $day_num <= $days_in_month ) {
//--my addition to Yahoo variables 2 $unixtime = mktime(0,0,0,$month,$day_num,$year); $shadeday = date('D' , $unixtime);
if ($shadeday != "Sun" && $shadeday != "Sat") { echo "<td><a class='$class' target='_blank' href='$yahoo/?v=0&t=$unixtime'> $day_num </a></td>\n"; } else { echo "<td> $day_num </td>\n"; } $day_num++; $day_count++;
//Make sure we start a new row every week if ($day_count > 7) { //check to see what css class is being used and switch classes if ( $row == 1 ) { echo "</tr><tr class=\"even\">\n"; $row = 2; } else { echo "</tr><tr class= \"odd\">\n"; $row = 1;
}
$day_count = 1; } }
//Finaly we finish out the table with some blank details if needed while ( $day_count >1 && $day_count <=7 ) { echo "<td> </td>"; $day_count++; }
echo "</tr></table>";
?>
</body>
Reply
jlhaslip
Oct 3 2006, 06:40 AM
Couple of changes on this demo here. http://www.jlhaslip.trap17.com/cal_test/test3.phpCSS was altered. Now links to my calendar. Adjusted to my time zone. Added "add an event" button for web based changes by others IF your yahoo calendar allows them to modify the calendar. Add an individual user to your approved modifier list through Yahoo! calendar set up screen via your Yahoo! account. Also, use the Yahoo! Calendar to make the calendar Public. CODE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Cal test 3</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" > <meta http-equiv="Content-Style-Type" content="text/css" > <style type="text/css">
body { background-color: #eeeeee; font: 0.85em Arial,Helvetica,Verdana, sans-serif, serif; min-height: 100%; margin-left:auto; margin-right:auto; text-align:center;
}
table, tr, td { margin-left:auto; margin-right:auto; text-align:center;
}
a:link, a:visited { color: #ff6666; border-left: 3px solid #cc9966; border-bottom: 3px solid #cc9966; border-right: 3px solid #996633; border-top: 3px solid #996633; font-weight: bold; display:block; text-decoration:none; } a:hover { background-color: #eecc33; color: #996633; border-left: 3px solid #996633; border-bottom: 3px solid #996633; border-right: 3px solid #cc9966; border-top: 3px solid #cc9966; }
// use the classes odd and even for the colors of the shaded rows
.odd {background-color: #eeeeee; }
.even {background-color: #cccccc; } .highlight {background-color: #ddcccc; }
a.highlight {background-color: #dd9999; color:#666666; }
a:hover.highlight {background-color: #ee6666; color:#dddddd; }
</style> </head>
<body> <h4>Linking all days of the month<br />Shading alternate weeks<br />Highlight of the current date</h4>
<?php //--my addition to Yahoo variables
// var $yahoo defines the link which control is passed to
$yahoo = "http://calendar.mail.yahoo.com/jlhaslip"; // var $view defines the query string value to define the view used by $yahoo // uncomment the desired view // only one should be uncommented at a time
$view = 0; // daily view //$view = 1; // weekly view //$view = 2; // monthly view //$view = 3; // yearly view //$view = 4; // daily view //$view = 5; // add event view
//This gets today's date $date =time () + (60 * 60 * -7); //This puts the day, month, and year in seperate variables $day = date('d', $date) ; $month = date('m', $date) ; $year = date('Y', $date) ;
// use the row variable to switch shading on each line $row = 2;
//Here we generate the first day of the month $first_day = mktime(0,0,0,$month, 1, $year) ;
//This gets us the month name $title = date('F', $first_day) ;
//Here we find out what day of the week the first day of the month falls on $day_of_week = date('D', $first_day) ;
//Once we know what day of the week it falls on, we know how many blank days occur before it. //If the first day of the week is a Sunday then it would be zero switch($day_of_week){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; }
//We then determine how many days are in the current month $days_in_month = cal_days_in_month(0, $month, $year) ;
//Here we start building the table heads echo "<table border=1 width=200>"; echo "<tr class=\"even\"><th colspan=7> $title $year </th></tr>"; echo "<tr class=\"odd\"> <td width=25 align=center>S</td> <td width=25 align=center>M</td> <td width=25 align=center>T</td> <td width=25 align=center>W</td> <td width=25 align=center>T</td> <td width=25 align=center>F</td> <td width=25 align=center>S</td> </tr>";
//This counts the days in the week, up to 7 $day_count = 1;
echo "<tr class=\"even\">"; //first we take care of those blank days while ( $blank > 0 ){ echo "<td></td>\n"; $blank = $blank-1; $day_count++; }
//sets the first day of the month to 1 $day_num = 1;
//count up the days, untill we've done all of them in the month while ($day_num <= $days_in_month ) {
//--my addition to Yahoo variables 2 $unixtime = mktime(0,0,0,$month,$day_num,$year); $shadeday = date('D' , $unixtime);
//if ($shadeday != "Sun" && $shadeday != "Sat") { if ( $day_num == $day) { echo "<td><a class=\"highlight\" href='$yahoo/?v=$view&t=$unixtime'> $day_num </a></td>\n"; } else { echo "<td><a href='$yahoo/?v=$view&t=$unixtime'> $day_num </a></td>\n"; } // } // else { // echo "<td> $day_num </td>\n"; // } $day_num++; $day_count++;
//Make sure we start a new row every week if ($day_count > 7) {
//check var $row, switch classes / re-set $row as required if ( $row == 1 ) { echo "</tr><tr class=\"even\">\n"; $row = 0; } else { echo "</tr><tr class= \"odd\">\n"; $row = 1; }
$day_count = 1; }
}
//Finaly we finish out the table with some blank details if needed while ( $day_count >1 && $day_count <=7 ){ echo "<td> </td>"; $day_count++; }
echo "</tr></table><table><tr><td class='highlight'><a href='$yahoo/?v=5'>Click to add an event </a></td><tr>\n"; echo "</table>";
?>
</body>
Reply
jlhaslip
Oct 11 2006, 04:02 AM
Well, I hate double posting, but here goes... Still playing with this thing a little and here is what I have so far: Version #9 used for testing - loops back to the php_self address Header lists the filename, displays flag settings in footer Test 9Version #10 Full linking mode, no styling used Test 10Version #11 Full styling, Footer announcement, clickable Full Header, no flags displayed. Test 11Hope you like them.
Reply
Recent Queries:--
php yahoo calendar export - 33.07 hr back. (1)
-
php sport calendar script - 130.60 hr back. (1)
-
php hockey calendar script - 132.17 hr back. (1)
Similar Topics
Keywords : simple, php, calendar, yahoo, calendar, connection, linking, date, yahoo, calendar
- Php Date()?
timezone is offset (4)
Will This Code Work
php linking script ?p= (5) hi i'm not that great at php so i'm not to sure if this will work or not. but what i want to
do is be able to use ?p=staff or what ever page name, with out the php extion, and i would like to
no if this simple script i made would work. the code is: CODE <?php $p =
$_GET['p']; if ( !empty($p) &&
file_exists('./' . $p . '.php') && stristr( $p, '.'
) == False ) { // pages = directory where you store your pages $file = './'
. $p . '....
Displaying Date And Time (gmt+8)
(5) how to display date and time (gmt+8)? any help would be appreciated.....
Php Date() Problem [resolved]
date() seems to loop same ninute. (4) My setup is a macbook pro and I have apache+ mysql + php already included I think. the php is
version 4.4.4 I have been using the date() to store dates into my mysql tables in the past and it
worked corectly. I dont know what could of happen but now the date() function is returning an
incorrect time. I made a test script test.php CODE <?php $date_time =
date('y-m-d H:m:s'); echo($date_time); ?> and loaded
it up. My laptops system time would be 1.35.33 PM and the date and time returned from php would be
07-....
Display The Current Date/time
With a simple PHP code (3) Use this code to display the current date and time. CODE <?php $date =
date('l dS \of F Y h:i:s A'); echo "$date"; ?>
"l" would display the current day of the week such as Sunday. d displays the day of the month...
such as 1 and S adds the appropriate suffix(st). /of simply displays the word "of". F displays the
current month with no abbreviations while Y displays the four digit year(2007). "h" displays the
current hour with leading zeros if necessary(Ex. 06 for 6 o'clock). "i" displays the m....
Php Calendar
Question (1) Hi Dears i wankt make one php photo blog i need Calendar soruce . i search at google but i can not
find really nice and free Calendar sample . if you have good Calendar sample plz post here Next
question : Are you like Calendar in your photo blog ? its really shoud in photoblog script or not ?
i never see members use Calendar Calendar obj is important for one script or not ? Thanks
Dear's....
Myodbc 3.51.11-2 And Ups Worldship Connection Problem
(0) Hi everyone!
I am trying to set
up an export map from UPS's WorldShip software to MySQL Server using WorldShip's built-in
feature for this purpose and MyODBC 3.51.11-2 on Windows Platform (WinXP and Win2000).
Basically this involves setting up an ODBC DSN to connect to the My....
How Yahoo! Publish News ?
(3) I want to know how the websites like www.myway.com publish news? They do not have their own news ..
they take from other sources... for example reuters.. most of the news from yahoo are from AP.. of
course these websites are very big and they have some professional services..but i just want to know
, how does this work ? What is the way to publish news on website ? Is there any news services
which allows to print the complete news articles on others website ? Usually rss news prints only
headlines.. if there is any information about it please let me know.....
Adding One Day To Date
i'd like to add one day to date (3) I would like to add one day to date.Doesn't any one have a simple code that I can have. or mabe
a link. date("Y-m-d H:i:s") + (1800 * 24);//this doesnt work ;/ but i need to have 24 hours after
date for a check. Thanks for taking the time i hope some one can help me out. Dont warry about it
if you dont have some thing already made. ....
Phpbb V2.0.16 Has Been Released
Release Date 06/27/05 (4) QUOTE phpBB Group announces the release of phpBB 2.0.16. This release addresses some bugfixes
and one critical security issue. http://www.phpbb.com/phpBB/viewtopic.php?f=14&t=302011 ....
Calendar
(7) im making a comic news script that stores the link to the picture, the title and news in mysql with
the date i want a calendar that makes each day a link if i posted something for that date say i
posted something on June 21 on the calendar all the date will be plain text, but the 21 will be a
link to the news post how would i do something like that i think wordpress has something like this....
Question About The Date() Function In Php
(4) Hi this is the code I've been using. This works perfectly fine with mysql but I'm having
trouble with getting the exact time. It probably has something to do with time zones and countries.
Is there something that I need to set to get the time right? I'm from the Philippines and we
have the same time as Singapore and HongKong. Help please. Tnx. /huh.gif' border='0'
style='vertical-align:middle' alt='huh.gif' /> CODE $date = date('H:i A, jS
F Y'); ....
Looking for simple, php, calendar, yahoo, calendar, connection, linking, date, yahoo, calendar
|
|
Searching Video's for simple, php, calendar, yahoo, calendar, connection, linking, date, yahoo, calendar
|
advertisement
|
|