You are here: Re: detecting user's timezone « PHP Programming Language « IT news, forums, messages
Re: detecting user's timezone

Posted by Rami Elomaa on 07/08/07 08:54

newbie kirjoitti:
> Hi,
>
> I wonder if it's possible to detect a user (the browser's) timezone
> when he/she access my php file? I saw ppl suggesting using javascript
> to collect that information. But I wonder if it's possible to do it
> without the headache of javascript.

Really isn't much of a headache. All you do is add a hidden field and a
tiny tiny script snippet. If the field is blank, user is not using
javascript so you'll just display it as GMT. To fill the field just use
something like this:

<input name="timezone" id="timezone" type="hidden" value="" />
<script type="text/javascript">
document.getElementById('timezone').value = new
Date().getTimeZoneOffset(); // this should all be in one line
</script>

And there you have it, no headache at all.

--
Rami.Elomaa@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация