Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Daylight savings time etc...

Reply
Thread Tools

Daylight savings time etc...

 
 
jodleren
Guest
Posts: n/a
 
      06-05-2009
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



 
Reply With Quote
 
 
 
 
GArlington
Guest
Posts: n/a
 
      06-05-2009
On Jun 5, 2:05*pm, jodleren <(E-Mail Removed)> wrote:
> 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?
 
Reply With Quote
 
 
 
 
Dr J R Stockton
Guest
Posts: n/a
 
      06-05-2009
In comp.lang.javascript message <b3d6b08c-51db-43b9-9ff9-d2cf3ba529ee@o1
4g2000vbo.googlegroups.com>, Fri, 5 Jun 2009 06:05:38, jodleren
<(E-Mail Removed)> posted:
>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, go via <URL:http://www.merlyn.demon.co.uk/js-dates.htm>.

>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.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF3 Op9 Sf3
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simplest way to display time with correct daylight savings? lordy Java 3 07-14-2006 04:33 PM
Daylight Savings time configuration Andrew Barnes Cisco 2 03-24-2006 06:45 PM
Help with DateTime and TimeZones / DayLight savings time Ryan Ternier ASP .Net 1 10-14-2005 05:20 PM
Daylight savings time...... XtremeHOHA Computer Support 5 01-15-2005 11:16 PM
No daylight savings checkbox in my date/time control panel in winXP Jim Kroger Computer Support 2 10-14-2003 09:55 PM



Advertisments