Getting user TimeZone 
Author Message
 Getting user TimeZone

Hi,

I'm using a perlscript to get some user input and I'd like to know the
users TimeZone.
I can't find it in the %ENV table is there any way I can get it?

I'm not sure this is the right forum, if not plz let me know :)

Regards
/Kjell



Thu, 12 Aug 2004 13:36:33 GMT  
 Getting user TimeZone

Quote:

> I'm using a perlscript to get some user input and I'd like to know the
> users TimeZone.
> I can't find it in the %ENV table is there any way I can get it?

If $ENV{'TZ'} exists, then you should use it. Otherwise, check for a
symbolic link to zoneinfo. I believe that's what localtime does. On my
system, I do not have TZ set, but /etc/localtime is a symbolic link to
/usr/share/zoneinfo/US/Eastern, so perl can tell I'm in the US Eastern
time zone from this.

  $ perl -le 'print scalar localtime'
  Sun Feb 24 09:36:05 2002

But if I want to pretend I'm in, say New Zealand, perl will honor that

  $ TZ=NZ perl -le 'print scalar localtime'
  Mon Feb 25 03:36:14 2002

Unfortunately, I don't think those filenames are universal. Your
zoneinfo may be elsewhere (you may even have an environment variable
called TZDIR which tells you where).

Alternatively, you could calculate the time locally, convert it to UCT
with the Time::Local module, and then check the difference. Something
like

  use Time::Local;
  $now = time;
  ($sec,$min,$hour,$mday,$mon,$year) = localtime $now;
  $time = timegm($sec,$min,$hour,$mday,$mon,$year);
  $diff = ($time - $now)/60;
  print "The difference between your time zone and UCT is $diff minutes.\n";

I hope this helps,

Tim



Thu, 12 Aug 2004 15:49:02 GMT  
 Getting user TimeZone
Thanx for trying Tim,
but I know my own TZ it's the website users TZ I'm interested in.

/Kjell

Quote:


> > I'm using a perlscript to get some user input and I'd like to know the
> > users TimeZone.
> > I can't find it in the %ENV table is there any way I can get it?

> If $ENV{'TZ'} exists, then you should use it. Otherwise, check for a
> symbolic link to zoneinfo. I believe that's what localtime does. On my
> system, I do not have TZ set, but /etc/localtime is a symbolic link to
> /usr/share/zoneinfo/US/Eastern, so perl can tell I'm in the US Eastern
> time zone from this.

>   $ perl -le 'print scalar localtime'
>   Sun Feb 24 09:36:05 2002

> But if I want to pretend I'm in, say New Zealand, perl will honor that

>   $ TZ=NZ perl -le 'print scalar localtime'
>   Mon Feb 25 03:36:14 2002

> Unfortunately, I don't think those filenames are universal. Your
> zoneinfo may be elsewhere (you may even have an environment variable
> called TZDIR which tells you where).

> Alternatively, you could calculate the time locally, convert it to UCT
> with the Time::Local module, and then check the difference. Something
> like

>   use Time::Local;
>   $now = time;
>   ($sec,$min,$hour,$mday,$mon,$year) = localtime $now;
>   $time = timegm($sec,$min,$hour,$mday,$mon,$year);
>   $diff = ($time - $now)/60;
>   print "The difference between your time zone and UCT is $diff minutes.\n";

> I hope this helps,

> Tim



Thu, 12 Aug 2004 15:55:32 GMT  
 Getting user TimeZone

Quote:



> > > I'm using a perlscript to get some user input and I'd like to know the
> > > users TimeZone.
> > > I can't find it in the %ENV table is there any way I can get it?

> > If $ENV{'TZ'} exists, then you should use it. Otherwise, check for a
> > symbolic link to zoneinfo. I believe that's what localtime does. On my
> > system, I do not have TZ set, but /etc/localtime is a symbolic link to
> > /usr/share/zoneinfo/US/Eastern, so perl can tell I'm in the US Eastern
> > time zone from this.

> >   $ perl -le 'print scalar localtime'
> >   Sun Feb 24 09:36:05 2002

> > But if I want to pretend I'm in, say New Zealand, perl will honor that

> >   $ TZ=NZ perl -le 'print scalar localtime'
> >   Mon Feb 25 03:36:14 2002

> > Unfortunately, I don't think those filenames are universal. Your
> > zoneinfo may be elsewhere (you may even have an environment variable
> > called TZDIR which tells you where).

> > Alternatively, you could calculate the time locally, convert it to UCT
> > with the Time::Local module, and then check the difference. Something
> > like

> >   use Time::Local;
> >   $now = time;
> >   ($sec,$min,$hour,$mday,$mon,$year) = localtime $now;
> >   $time = timegm($sec,$min,$hour,$mday,$mon,$year);
> >   $diff = ($time - $now)/60;
> >   print "The difference between your time zone and UCT is $diff minutes.\n";

> > I hope this helps,

> > Tim

> Thanx for trying Tim,
> but I know my own TZ it's the website users TZ I'm interested in.

> /Kjell

Then maybe you should have mentioned that in your original post...

I suggest you use JavaScript to read a remote user's clock setting. JS
has the getTimezoneOffset which may be what you need. See
http://tech.irt.org/articles/js076/ for more info.



Thu, 12 Aug 2004 17:01:12 GMT  
 Getting user TimeZone

[ top-posting rearranged ]

Quote:
>> On Sun, 24 Feb 2002 16:55:32 +0200,

> Thanx for trying Tim, but I know my own TZ it's the
> website users TZ I'm interested in.

Aaah, a stealth CGI question then.  How is anyone supposed
to know this if you don't tell us?

You'll have to write some code that asks the user what
their time zone is, and get them to type it in to a form
or phone you or something.

There's no reason that a web browser, or robot or
whatever, would reveal its time zone to you.  And even if
it did, there's no way of knowing if it is the time zone
of the "real" user sat at a terminal (think: corporate
proxy).

But there's no reason to believe me in clpm.  This has
nothing do with perl per se (or should that be "perl
se"?).  You need to go to the comp.infosystems.www
hierarchy and ask in an appropriate group there.

hth
t
--
Oh!  I've said too much.  Smithers, use the amnesia ray.



Thu, 12 Aug 2004 16:59:45 GMT  
 Getting user TimeZone
This person did mention it in the original post though.

"I'm using a perlscript to get some user input and I'd like to know the
users TimeZone."


Quote:



> > > > I'm using a perlscript to get some user input and I'd like to know
the
> > > > users TimeZone.
> > > > I can't find it in the %ENV table is there any way I can get it?

> > > If $ENV{'TZ'} exists, then you should use it. Otherwise, check for a
> > > symbolic link to zoneinfo. I believe that's what localtime does. On my
> > > system, I do not have TZ set, but /etc/localtime is a symbolic link to
> > > /usr/share/zoneinfo/US/Eastern, so perl can tell I'm in the US Eastern
> > > time zone from this.

> > >   $ perl -le 'print scalar localtime'
> > >   Sun Feb 24 09:36:05 2002

> > > But if I want to pretend I'm in, say New Zealand, perl will honor that

> > >   $ TZ=NZ perl -le 'print scalar localtime'
> > >   Mon Feb 25 03:36:14 2002

> > > Unfortunately, I don't think those filenames are universal. Your
> > > zoneinfo may be elsewhere (you may even have an environment variable
> > > called TZDIR which tells you where).

> > > Alternatively, you could calculate the time locally, convert it to UCT
> > > with the Time::Local module, and then check the difference. Something
> > > like

> > >   use Time::Local;
> > >   $now = time;
> > >   ($sec,$min,$hour,$mday,$mon,$year) = localtime $now;
> > >   $time = timegm($sec,$min,$hour,$mday,$mon,$year);
> > >   $diff = ($time - $now)/60;
> > >   print "The difference between your time zone and UCT is $diff
minutes.\n";

> > > I hope this helps,

> > > Tim

> > Thanx for trying Tim,
> > but I know my own TZ it's the website users TZ I'm interested in.

> > /Kjell

> Then maybe you should have mentioned that in your original post...

> I suggest you use JavaScript to read a remote user's clock setting. JS
> has the getTimezoneOffset which may be what you need. See
> http://tech.irt.org/articles/js076/ for more info.



Thu, 12 Aug 2004 19:53:38 GMT  
 Getting user TimeZone
oki, so it's a no can do to geti ti without user intervention. Guess I
have to accept that, I thought it would come handy with the rest of the

Thanx for helping me out, hope to be able to return it some day
/Kjell

Quote:

> [ top-posting rearranged ]

> >> On Sun, 24 Feb 2002 16:55:32 +0200,

> > Thanx for trying Tim, but I know my own TZ it's the
> > website users TZ I'm interested in.

> Aaah, a stealth CGI question then.  How is anyone supposed
> to know this if you don't tell us?

> You'll have to write some code that asks the user what
> their time zone is, and get them to type it in to a form
> or phone you or something.

> There's no reason that a web browser, or robot or
> whatever, would reveal its time zone to you.  And even if
> it did, there's no way of knowing if it is the time zone
> of the "real" user sat at a terminal (think: corporate
> proxy).

> But there's no reason to believe me in clpm.  This has
> nothing do with perl per se (or should that be "perl
> se"?).  You need to go to the comp.infosystems.www
> hierarchy and ask in an appropriate group there.

> hth
> t
> --
> Oh!  I've said too much.  Smithers, use the amnesia ray.



Thu, 12 Aug 2004 20:40:00 GMT  
 Getting user TimeZone
Quote:

> This person did mention it in the original post though.

what? don't top-post, please

Quote:
> "I'm using a perlscript to get some user input and I'd like to know the
> users TimeZone."





>> > > > I'm using a perlscript to get some user input and I'd like to know
> the
>> > > > users TimeZone.
>> > > > I can't find it in the %ENV table is there any way I can get it?

[some solutions]

Quote:
>> > Thanx for trying Tim,
>> > but I know my own TZ it's the website users TZ I'm interested in.

>> Then maybe you should have mentioned that in your original post...

well, the original question was:

Quote:
>> > > > I'm using a perlscript to get some user input and I'd like to know
> the
>> > > > users TimeZone.
>> > > > I can't find it in the %ENV table is there any way I can get it?

where can you see the word "website" or CGI in this question?
you can write perl-scripts which take user-input from the
command line or STDIN (or from %ENV, which is also not
CGI-only).

regards, tina
--
http://tinita.de                    \  enter__| |__the___ _ _ ___
PerlQuotes: http://tinita.de/pq.html \     / _` / _ \/ _ \ '_(_-< of
MovieDB: http://tinita.de/tmdb.html   \    \ _,_\ __/\ __/_| /__/ perception



Fri, 13 Aug 2004 01:20:49 GMT  
 Getting user TimeZone

Quote:
> This person did mention it in the original post though.

Where???

Quote:
> "I'm using a perlscript to get some user input and I'd like to know the
> users TimeZone."

I don't see a single reference whatsoever to CGI or web authoring or HTML or
... in the sentence you quoted above.

jue



Fri, 13 Aug 2004 19:25:18 GMT  
 Getting user TimeZone
Hi all and thanx for trying to help me out.
I guess I wasn't too clear in the post about being on the web. Sorry for
that.

However, I have found a solution that might be interesting for some of
you. Via Javascript to a hidden field I can get the webusers TimeZone.
Just to include som Javascripting to the page and voil.

SeaU
/Kjell

Quote:

> Hi,

> I'm using a perlscript to get some user input and I'd like to know the
> users TimeZone.
> I can't find it in the %ENV table is there any way I can get it?

> I'm not sure this is the right forum, if not plz let me know :)

> Regards
> /Kjell



Sat, 14 Aug 2004 19:32:44 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Need help with getting timezone from date

2. Getting IP address of user who has submitted information from a Web page

3. Getting and using dates from user entry

4. getting user input oddity (for a newbie anyways :)

5. getting env of another user

6. Getting .htpasswd user name from CGI

7. Getting Users' IP

8. getting users ip

9. getting files from a user through the internet

10. Getting and using dates from user entry

11. Getting user last login time and date from perl

12. Getting HTTPD-User-Manage working on Apache 1.3.9 on NT

 

 
Powered by phpBB® Forum Software