mtWeb  Home > Download > Display local timeSitemap  Search

Display local time

Posted by martin on 30 Jul 2002.

PHP code letting you display the visitor's localtime on your generated pages.

Download

localtime.php, downloaded 8099 times.
Complete code

Changelog

30 Jul 2002

  • First released

Comments

How to tdownload the code
by Abhijit Patil (abhipatil_2001@yahoo.com) on 1 Oct 2002 4:38am GMT

Your logic is excellent. But download link is not proper. Please tell me how to tdownload the code.

Download the code
by martin on 1 Oct 2002 7:39pm GMT

Abhijit, either your browser incorrectly states that it can accept gzip or deflate encoding or there was something wrong with my server at the time you tried to download the file. Try again with a different browser.

Displaying Local Time
by Bruno Verrillo (brunoverrillo@hotmail.com) on 5 Nov 2002 3:20pm GMT

Hi

I am completely new to this and don't have a clue where to start.

What I need is some kind of script php or otherwise, to display a local time clock for any specific city anywhere in the world.

e.g. I am looking at a page and can see a clock displaying New York's local time, I will then go to another page and see a clock displaying London's local time.

How do I go about making this scipt? Any help will be greatly appreciated!

Thanks

Bruno

Multiple times
by martin on 5 Nov 2002 4:18pm GMT

You need to add another parameter or use an on-page method to determine the right time zone.

localtime.php
by carmen (calex@vglnet.com) on 5 Nov 2002 7:28pm GMT

Hello Martin,

I placed localtime.php into the same directory as my webpages. I also added the php/javascript part into my index.html page (into the body). Nothing happens.

What am I doing wrong?

Thanks!

Re: Localtime
by martin on 6 Nov 2002 9:42am GMT

Carmen, you need PHP support.

If you have PHP support, just rename index.html to index.php and then it should run.

To see the effect you need to at least follow one link (forms don't work).

offset in seconds.
by ed (edspace2@yahoo.com) on 27 Feb 2003 3:04pm GMT

Hello.

I found this page because I am having problems with cookies not expiring in time in IE. IE cookies are expiring later because the server and local time are in different time zones. To fix this problem I wanted to set the cookies based on the user's local time. I am not interested in displaying the date/time. I just want to know the offset in seconds so I can use it to set cookies like this.

setcookie("cookie",1,time() + $_SESSION['GMT_offset'] + 120 )

That is going to set the cookie to expire in 2 minutes in local time.

Is that line correct? Since I need to include your code in every page I don't know if it is going to slow down my page execution time.

Java script
by Trausti Tomasson (traustito@caa.is) on 28 Feb 2003 10:21am GMT

Hi, I need a script to display local time in Iceland which is always GMT. I will be using this script on the Web page www.keflavikairport.com

Do you know where I can get this script??

parse error
by leo (a_abudok@yahoo.com) on 11 Apr 2003 9:24am GMT

i copied the whole code, and save it as localtime.php, but when i open it

an error like Parse error: parse error, unexpected '{' in /home/gwconnect/localtime.php on line 16

appears...what would be the problem

TY

Thanks
by tom () on 30 Apr 2003 4:38pm GMT

Cool - thank you.

works great
by jub () on 2 May 2003 4:51pm GMT

good idea. works great.

needed
by abdi (abdi_182@hotmail.com) on 20 May 2003 8:27am GMT

i needed script php :

1. news can to update

2. vote

3. guestbook

4. templates

Error on Function
by majagua (ifsavel@eia.edu.co) on 23 Jun 2003 7:55pm GMT

Im a newbie and I included the file in my php pages, but I get parse error on line 16. What could be the problem?

Thanks.

Date
by Martin (Noelzk@Yahoo.com) on 11 Jun 2004 10:44am GMT

How To display the date on the web page, because, from java script i have, i can't change the script to php script

Display Local Time Automatically
by Charles (tzyychau_1980@hotmail.com) on 9 Sep 2004 5:36pm GMT

I still dont know how to start after reading through the code. Could you give me more details. Thanks for your help.

n00b r teh sux
by MIke () on 9 Sep 2004 8:43pm GMT

Damn, you got all these n00bs posting and asking stupid questions. I guess thats whatcha get for rippin' this tutorial from php9.com

Local time adjust globally if .htaccess
by bearded (rch_kislaya@sancharnet.in) on 16 Sep 2004 2:27am GMT

I am a new PHP-user. I have problems with date-time scripts at my server. Is there any way to set (like .htaccess file) all my php scripts to adjust automatically with local time, other than server time?

may i can get this code ?
by taupaypay (taupaypay@yahoo.com) on 5 Nov 2004 4:22pm GMT

thanks for all