[Web4lib] How to feed Today's Library Hours to home page?

Sutherland, Michael msutherland at montana.edu
Wed Apr 29 15:33:51 EDT 2009


I've been working on this for our Web site recently in PHP. 

What I did was to query the server in PHP using the date function 

$today = date('H,i,s,n,j,Y');

and changed this into the Unix timestamp using mktime 

$today = mktime($today);

The holidays are kept in a comma separated value (.csv) file, which
could be edited by anyone. Then I load the exceptions from the file into
a multidimensional array. I check the date against values in the array.
If it finds a match it loads the hours for the exception. If no matches
are found in the exceptions, then it loads the correct semester hours
from a reusable function.  Since the timestamp is a long integer
containing the number of seconds between the Unix epoch (January 1,
1970) and the date specified, it is easy to compare these numbers, a
simple if-else statement. If you have different hours for the day of the
week, as we do, and for different branches, then you can make another
variable using the date function - 

$day = date('l');  to give you the day of the week and put the hours
based on the day.   

The instructions for using date() and mktime() are all in the PHP manual
online; just Google php mktime or php date. The manual has code snippets
that you can re-use to your own needs.  

If you want to see the code I wrote, feel free to contact me. 

Michael

------------------------------------------------------- 
Michael Sutherland 
Web Services Librarian/Assistant Professor
Montana State University Libraries 
P.O. Box 173320 
Bozeman, MT, USA 59717-3320 
Ph: (406) 994-6429 
msutherland at montana.edu 


-----Original Message-----
From: web4lib-bounces at webjunction.org
[mailto:web4lib-bounces at webjunction.org] On Behalf Of Ingrid Redman
Sent: Tuesday, April 28, 2009 1:48 PM
To: web4lib at webjunction.org
Subject: [Web4lib] How to feed Today's Library Hours to home page?

Hello,

 

I would like to display "Today's Open Hours" on our library home page in
an
automatic fashion.  Currently our hours are available in a google
calendar
(http://www.poly.edu/library/services/hours.php) and I was thinking I
could
set up a  feed to the home page with just today's hours, but I'm not
sure
how.

 

Does anyone have experience doing this kind of thing with Google
calendars?
Or could you recommend another solution?  I'm not much of a coder.

 

Thanks for your help,

 

Ingrid

 

________________________________________

Ingrid Redman

Web Librarian | Bern Dibner Library of Science and Technology

Polytechnic Institute of NYU | 5 MetroTech Center | Brooklyn NY 11201

Tel: 718 260 3672 | Fax: 718 260 3756 | Web:
<http://www.poly.edu/library>
www.poly.edu/library

 

_______________________________________________
Web4lib mailing list
Web4lib at webjunction.org
http://lists.webjunction.org/web4lib/





More information about the Web4lib mailing list