Daylight savings time etc...

J

jodleren

I just got an idea... as others working with time / ajax getting a
correct timer is a problem.

I looks at

d = new Date();
offset=Math.abs(d.getTimezoneOffset())/60

but that returns 3, while I am at GMT+2. date.getHours adds tne 2 hrs
causing my probvlem.
Then I realised, that the answer is in front of me.

var d = new Date();
t=new Date(new Date() - d);
offset=t.getHours(); // time offset!

This is what I am looking for at all times.
Probably there is a better way of getting the time "0", but I am not
that much a java freek

WBR
Sonnich
 
G

GArlington

I just got an idea... as others working with time / ajax getting a
correct timer is a problem.

I looks at

  d = new Date();
  offset=Math.abs(d.getTimezoneOffset())/60

but that returns 3, while I am at GMT+2. date.getHours adds tne 2 hrs
causing my probvlem.
Then I realised, that the answer is in front of me.

    var d = new Date();
    t=new Date(new Date() - d);
    offset=t.getHours(); // time offset!
I suspect that offset == 0 here...
This is what I am looking for at all times.
Probably there is a better way of getting the time "0", but I am not
that much a java freek
It is NOT Java, it is JavaScript
WBR
Sonnich

I can not understand what you were trying to do...
Get server time (???) and display it in browser timezone?
Something else?
 
D

Dr J R Stockton

In comp.lang.javascript message <b3d6b08c-51db-43b9-9ff9-d2cf3ba529ee@o1
4g2000vbo.googlegroups.com>, Fri, 5 Jun 2009 06:05:38, jodleren
I just got an idea... as others working with time / ajax getting a
correct timer is a problem.

I looks at

d = new Date();
offset=Math.abs(d.getTimezoneOffset())/60
********
So you don't care whether you are in Estonia or half-way across the
Atlantic?
but that returns 3, while I am at GMT+2. date.getHours adds tne 2 hrs
causing my probvlem.
Then I realised, that the answer is in front of me.

var d = new Date();
t=new Date(new Date() - d);
offset=t.getHours(); // time offset!

The argument of t = new Date( ) will probably be zero, otherwise a
small positive integer. Therefore, T will represent 1970-01-01 00:00:00
and maybe a few milliseconds. You could more easily have used T = new
Date(0) .

For locations where News Year's Day uses Standard Time, that will give
the number of your Time Zone, with London being in Zone 0 and increasing
Eastwards to the Azores & Cape Verde.

For locations where New Year's Day uses Summer Time like Wagga Wagga and
Waitangi, it will be wrong by an hour. I'm not sure what LHI should
give.


To get the nominal central longitude, or number, of the local time zone,
correctly said:
This is what I am looking for at all times.
Probably there is a better way of getting the time "0", but I am not
that much a java freek

The first thing to learn about a language is its name. Java questions
go in groups like comp.lang.java.programmer.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top