473,804 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

detecting user's timezone

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.
Thanks,
<?php
// (1) here I somehow get his/her timezone
// (2) here fill his/her login timestamp into database----
apparently, this timestamp should be converted to a unified time
zone.
?>

Jul 6 '07
18 12120
Jerry Stuckle kirjoitti:
Rami Elomaa wrote:
>ZeldorBlat kirjoitti:
> If you're converting the time to a "unified time zone" why do you care
what timezone they're in? Why would you be recording the time from
the client in your database?

Not record, just show. Naturally it makes sense to record a global
time timestamp, like GMT, but people still like to see a time
displayed in their local timezone, so the OP wants to know how to get
it and then convert GMT to local time, just for _displaying_ it to
user. It's common localization practise. Wikipedia for one does this.

I've got two analog clocks on the walls, a watch on my wrist, and a
digital clock on my toolbar. What makes you think I need your site to
tell me what time it is?

As for Wikipedia - I don't see any clock on the pages when I view them.

You can include a clock if you want - but it looks stupid.
Oh good grief... Not a clock, TIME! Like for example: an auction that
ends on 12:00 am GMT time. I want to see it converted into my local,
Finland timezone, which would be 10:00am.

--
Ra*********@gma il.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Jul 8 '07 #11
Rami Elomaa wrote:
Jerry Stuckle kirjoitti:
>Rami Elomaa wrote:
>>ZeldorBlat kirjoitti:
If you're converting the time to a "unified time zone" why do you
care
what timezone they're in? Why would you be recording the time from
the client in your database?

Not record, just show. Naturally it makes sense to record a global
time timestamp, like GMT, but people still like to see a time
displayed in their local timezone, so the OP wants to know how to get
it and then convert GMT to local time, just for _displaying_ it to
user. It's common localization practise. Wikipedia for one does this.

I've got two analog clocks on the walls, a watch on my wrist, and a
digital clock on my toolbar. What makes you think I need your site to
tell me what time it is?

As for Wikipedia - I don't see any clock on the pages when I view them.

You can include a clock if you want - but it looks stupid.

Oh good grief... Not a clock, TIME! Like for example: an auction that
ends on 12:00 am GMT time. I want to see it converted into my local,
Finland timezone, which would be 10:00am.
That's not what we're talking about here, Rami.

And I want to see how many hours and minutes before it ends.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 8 '07 #12
In message <11************ **********@z28g 2000prd.googleg roups.com>
newbie <mi******@yahoo .comwrote:
>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.
Would it not be possible to do this from their IP address?

--
Kev Wells http://kevsoft.topcities.com
http://kevsoft.co.uk/
ICQ 238580561
Useless Fact 04 The number of islands around mainland Britain is 6289.
Jul 8 '07 #13
In our last episode,
<16************ **@talktalk.net >,
the lovely and talented Kevin Wells
broadcast on comp.lang.php:
In message <11************ **********@z28g 2000prd.googleg roups.com>
newbie <mi******@yahoo .comwrote:
>>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.
Would it not be possible to do this from their IP address?
You could probably beat outright guessing in that way, but there is no
reliable relationship between IP and geography, no necessary relationship
between the IP making the request and the user's actual IP at any given
moment, and again no necessary relationship between the user's actual IP at
any moment and geography.

You might get it right most of the time, but you will get it wrong a
significant part of the time, and in some cases you'll get it wrong in an
absurd way --- such as claiming the page was last updated some time in the
future.

--
Lars Eighner <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 561 days to go.
Friends of Lizbeth: help replace failed a/c at Austin's no-kill shelter
<https://secure.groundsp ring.org/dn/index.php?aid=1 2349>
Jul 8 '07 #14
Lars Eighner wrote:
>Would it not be possible to do this from their IP address?

You could probably beat outright guessing in that way, but there is no
reliable relationship between IP and geography, no necessary relationship
between the IP making the request and the user's actual IP at any given
moment, and again no necessary relationship between the user's actual IP at
any moment and geography.
Guessing is a bit wrong. I would say guestimating.
You might get it right most of the time, but you will get it wrong a
significant part of the time, and in some cases you'll get it wrong in an
absurd way --- such as claiming the page was last updated some time in the
future.
Most of the times would be good enough for most of the sites. You can do
a first guestimate and then have a cookie so that people can change it
and have the correct time whenever they come back.

The accuracy would also depend on what you intend to do with it.

houghi
--
_______________ _________ Open your eyes, open your mind
| proud like a god don't pretend to be blind
| trapped in yourself, break out instead
http://openSUSE.org | beat the machine that works in your head
Jul 8 '07 #15
Kevin Wells wrote:
In message <11************ **********@z28g 2000prd.googleg roups.com>
newbie <mi******@yahoo .comwrote:
>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.

Would it not be possible to do this from their IP address?
Well, for instance, a lot of larger companies have a few proxies for
their users, and those proxies may or may not be in the same country -
much less the same time zone.

The same is true for some ISP's - like AOL.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 8 '07 #16
Jerry Stuckle kirjoitti:
Rami Elomaa wrote:
>Jerry Stuckle kirjoitti:
>>Rami Elomaa wrote:
ZeldorBlat kirjoitti:
If you're converting the time to a "unified time zone" why do you
care
what timezone they're in? Why would you be recording the time from
the client in your database?

Not record, just show. Naturally it makes sense to record a global
time timestamp, like GMT, but people still like to see a time
displayed in their local timezone, so the OP wants to know how to
get it and then convert GMT to local time, just for _displaying_ it
to user. It's common localization practise. Wikipedia for one does
this.
I've got two analog clocks on the walls, a watch on my wrist, and a
digital clock on my toolbar. What makes you think I need your site
to tell me what time it is?

As for Wikipedia - I don't see any clock on the pages when I view them.

You can include a clock if you want - but it looks stupid.

Oh good grief... Not a clock, TIME! Like for example: an auction that
ends on 12:00 am GMT time. I want to see it converted into my local,
Finland timezone, which would be 10:00am.

That's not what we're talking about here, Rami.
No, that's why I said it was an example. That was just an example of a
possible situation where a user might want to see a timestamp converted
to their local time.
And I want to see how many hours and minutes before it ends.
So it was not very good example. It was the first thing that I could
think of.

The original case was to let the user see when they last time logged in.
And the point of it all was how to aquire local timezone to display the
timestamp (which is stored in the database, perhaps as GMT) converted
into users local timezone. And this is what _I've_ been talking about
the whole time, believe it or not.

Please bare with me. If I don't make sense sometimes (or most of the
time) it's just because English isn't my native language. I do my best
to express myself but sometimes I obviously fail.

--
Ra*********@gma il.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Jul 8 '07 #17
Rami Elomaa wrote:
Jerry Stuckle kirjoitti:
>Rami Elomaa wrote:
>>Jerry Stuckle kirjoitti:
Rami Elomaa wrote:
ZeldorBla t kirjoitti:
If you're converting the time to a "unified time zone" why do
you care
>what timezone they're in? Why would you be recording the time from
>the client in your database?
>
Not record, just show. Naturally it makes sense to record a global
time timestamp, like GMT, but people still like to see a time
displayed in their local timezone, so the OP wants to know how to
get it and then convert GMT to local time, just for _displaying_ it
to user. It's common localization practise. Wikipedia for one does
this.
>

I've got two analog clocks on the walls, a watch on my wrist, and a
digital clock on my toolbar. What makes you think I need your site
to tell me what time it is?

As for Wikipedia - I don't see any clock on the pages when I view them.

You can include a clock if you want - but it looks stupid.
Oh good grief... Not a clock, TIME! Like for example: an auction that
ends on 12:00 am GMT time. I want to see it converted into my local,
Finland timezone, which would be 10:00am.

That's not what we're talking about here, Rami.

No, that's why I said it was an example. That was just an example of a
possible situation where a user might want to see a timestamp converted
to their local time.
>And I want to see how many hours and minutes before it ends.

So it was not very good example. It was the first thing that I could
think of.

The original case was to let the user see when they last time logged in.
And the point of it all was how to aquire local timezone to display the
timestamp (which is stored in the database, perhaps as GMT) converted
into users local timezone. And this is what _I've_ been talking about
the whole time, believe it or not.

Please bare with me. If I don't make sense sometimes (or most of the
time) it's just because English isn't my native language. I do my best
to express myself but sometimes I obviously fail.
Rami,

You're English is actually quite good, IMHO. And one can always argue
there are "reasons" for displaying certain information, like when the
user logged in. But that wasn't the question here.

And if you want to know what timezone they're in, just ask them and
store it in their profile. No problem and no JS needed.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jul 8 '07 #18
On Jul 8, 3:34 am, Rami Elomaa <rami.elo...@gm ail.comwrote:
ZeldorBlat kirjoitti:
If you're converting the time to a "unified time zone" why do you care
what timezone they're in? Why would you be recording the time from
the client in your database?

Not record, just show. Naturally it makes sense to record a global time
timestamp, like GMT, but people still like to see a time displayed in
their local timezone, so the OP wants to know how to get it and then
convert GMT to local time, just for _displaying_ it to user. It's common
localization practise. Wikipedia for one does this.

--
Rami.Elo...@gma il.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
Yes I also came to this conclusion after a client told me that he want
their site ready for 3-4 zone with differnt setting.

http://satya61229.blogspot.com

Jul 9 '07 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2136
by: Google Mike | last post by:
I guess I'm confused by the whole timezone thing and I don't want to write a web app that gets this stuff wrong. I don't know how timezones work exactly -- is it just hours +/- on GMT or are there going to be minor differences on minutes and seconds too? What I want to do is have a web app that one logs into (great place for submitting the browser's view on time via Javascript) and then the user sees the records from the database with...
9
3578
by: rick cameron | last post by:
TimeZone - the only instance you can get is one representing the local time zone DateTime - cannot represent a time before 00:00:00 1 Jan 1 CE What were they thinking? This is a serious question - can anyone come up with a good reason for these incredible design restrictions? Michael Brumm http://michaelbrumm.com has produced a fix for the first problem with his SimpleTimeZone class - good on you, Michael!
3
4519
by: Ilja Booij | last post by:
Hi all, I have some trouble with the following: I'm getting a time string, in YYYY-MM-DD HH:mm:ss format, which I need to translate into a string with DD-Mon-YYYY HH:mm:ss +HHMM, where the last part is the timezone offset. I've tried to do it with the following function. This works for me, I get +0200 for the timezone part, which makes sense, because we're
2
2105
by: Vaj | last post by:
hi, i would be very thankful if u can help me in solving this problem. my problem is i 've a page in that i'm displaying the creation dates of all files. these dates are like server dates . now i've to display these creationdates in the current logged in user desktop timezone. thanks
1
1128
by: googlegroups | last post by:
We have an application that is run in many timezones and uses remoting to access the DB. I have one screen that will only save if the user is in the same timezone as the server. I can reproduce this on my development machine by simply changing the timezone. When I use remoting and a different timezone, the remoting call hits the webserver (I verified through the web server logs), but never actually makes it to the DB. I put some code...
2
4069
by: Dotnet Gruven | last post by:
Hi, If a server is physically localled in CST and is shared, how can one create a Web Application on that server that has its timezone for EST??? I've seen other threads in this group that talk about using UTC/GMT and also getTimezoneOffset(), but in this case, the business rules are such that the Web App be based upon the time zone that the physical business is located. TIA,
0
2215
by: Ninja Zombie | last post by:
Hi all, is there maybe a property on the JCC driver which, when set, will convert the selected TIMESTAMP attribute to my local timezone. The database server is in the different timezone than the client, and I have set the java property 'user.timezone' on the client to my timezone. Thanks.
7
6227
by: David Thielen | last post by:
Hi; When I get a request how can I get the user's local DateTime? I can get ultureInfo.CurrentUICulture.Calendar for a calendar but I don't see any way to turn that in to a DateTime (although you would think that would be possible). Also, is there any way to set IE to have a different timezone than my system to test this on my system (so IE is set to pacific time but my "server" is on mountain time)?
2
3690
by: =?Utf-8?B?Sm9ubnk=?= | last post by:
I have an ASP.NET 2.0 C# web application that is contacting an Exchange server using WEBDAV. It allows the users to look up appointments for a future date. The problem I have is determining the correct client time zone. Note that Exchange stores everything in UTC time. I am able currently able to use javascript to ask the client what time zone they are in, but this is only for the "today" (the current day) and not for a day in the...
0
9712
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10089
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5530
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.