[nycphp-talk] timezone dropdown help
Brian Dailey
support at dailytechnology.net
Sat Jan 27 20:12:49 EST 2007
Check out timezone_abbreviations_list
http://us3.php.net/manual/en/function.timezone-abbreviations-list.php
It basically prints an array that contains each time zone and the offset
for that time zone. Maybe you can use that to get what you need.
- Brian
David Krings wrote:
> Aniesh joseph wrote:
>> hi
>>
>> I need to make a drop down in my web site in a registration form. From
>> the
>> drop down user can select the his desired time zone. My question is, I
>> want
>> to capture user's timezone using javascript and it will be shown as
>> slected
>> when at the time of registration. I got a javascript, it will capture
>> only timezoneoffset. Is anyrelation between timezone offset and name?
>> Is ie available as table? Can anyne help me to d this or by suggest
>> another method ?
>>
>> regards
>> joseph
>>
>
> Some time ago I asked a similar question and someone on this list was so
> nice to provide me with the ECMAScript for the client side to pull out
> the time zone bias.
>
> The general code is this one
>
> if(!isset($_COOKIE['GMT_bias'])) {
> ?>
> <script type="text/javascript">
> var Cookies = {};
> /***
> * @name = string, name of cookie
> * @value = string, value of cookie
> * @days = int, number of days before cookie expires
> ***/
> Cookies.create = function (name, value, days) {
> if (days) {
> var date = new Date();
> date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
> var expires = "; expires=" + date.toGMTString();
> } else {
> var expires = "";
> }
> document.cookie = name + "=" + value + expires + "; path=/";
> this[name] = value;
> }
> var now = new Date();
> Cookies.create("GMT_bias",now.getTimezoneOffset(),7);
> window.location = "<?php echo $_SERVER['PHP_SELF'];?>";
> </script>
> <?php
> } else {
> echo $_COOKIE['GMT_bias'];
> }
>
> It will simply echo the bias in minutes, which should be good enough to
> find out the client's time zone by name assuming you have some table for
> lookups or can pull that from the server system (no idea how that works,
> but other programming languages can do that. Since PHP can do anything
> including cooking breakfast, there should be some way).
>
>
> At least it gets you started.
>
> David
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
>
More information about the talk
mailing list