Jump to content

Clock Scripts


Recommended Posts

I dont know if this is possible or not, but I'm hoping someone will be able to point me in the right direction, if it is.

 

I want to make a webpage with a list of names, their local time, and their time zone, something like:

 

Person 1 08:45 Chicago

Person 2 10:45 New York

Person 3 18:45 London

Person 4 19:45 Rome

Person 5 05:45 Sydney

 

I know there are plenty of clock scripts out there that will produce my local time, but is there a script similar to this freely available?

Link to comment
Share on other sites

This is possible in a variety of ways. The first is to use google, lol and get one of the many free JavaScript world clocks, here are a couple:

 

http://www.arachnoid.com/lutusp/worldclock.html

http://www.javascriptkit.com/script/script...orldclock.shtml

 

However they might not suit your needs and it may be better to write your own if you can. Personally I would use PHP if you are on UNIX and take a server timestamp and then write a small function to adjust the result to the timezone offset.

 

Check out the time() or date() functions plus others here:

 

http://uk.php.net/manual/en/ref.datetime.php

 

Remember to check your servers timezone if it's hosted! It may be located in a different country.

Link to comment
Share on other sites

You dont say in what language, I presume PHP. Either way it can be achieved by having 2 database tables (persons and timezones). The person table stores their details and notably their timezone (e.g. NY, HK, GMT). The Timezones table has a list of timezones and their associated GMT offset (e.g +5)

 

Then its simply a matter of looping through the persons table, joining against the Timezone table. Doing so will give you their details and the timezone offset (+5). Simply get the current date/time in a var, then do a dateadd on the var using the offset to give you the resultant time. You can do even more tarty things when it comes to daylight saving and BST.

 

I could probably knock something up in ASP or PHP if you like.

Link to comment
Share on other sites

Well I'm not up to much when it comes to languages, so I didnt want to suggest any particular language, but php seems the way to go.

 

I had a browse through google this morning looking for world clocks and stuff, but all the ones I found didnt really work for what I wanted.. and I'm no good with php or javascript so its not like I could download one and modify it for myself.

 

Concrete, if I used your method, would it simply be a case of adding data to the table for it to automatically appear on the webpage, or does it take some editing to include anything new added to the table?

 

I was thinking that if you could set up the page for me, I can do the table myself if thats all I need to edit... still very new to php so excuse my n00bness :rolleyes:

Link to comment
Share on other sites

Concrete's method would be using a MySQL database hooked up to hold any info, like peoples names and their timezones/locations and the PHP will generate the results for you. This is the best option if you are continually adding or changing the people involved and you would probably setup a small admin page to edit/add/delete etc.

 

If it's simply a list of names and the timezones, then you could probably just hardcode it using arrays in PHP, which would mean you wouldn't need a Database. I guess you need to decide how often you are going to change the list and wether you have MySQL available on your server etc.

 

I'll let concrete take the lead on this Jools as he's offered to help already. But if you want any other help let me know.

 

:)

Link to comment
Share on other sites

  • 8 months later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...