Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > NZ Computing > An HTML question

Reply
Thread Tools

An HTML question

 
 
Philip
Guest
Posts: n/a
 
      01-02-2007
Is there an HTML function that can check the time in the computer it's
running on, and output a result reflecting the difference between that
time and NZ Standard, or Summer, time?

I want to put up a schdule for my radio stations, and be able to say to
people that might look at it from outside NZ, something like:

All times are n hours ahead of (or behind) (name of user's time zone)

So a user in Queensland might see:

Quensland time is three hours behind NZ time.

Even nicer would be to convert the NZ time listings, which are in a
simple table, to show the local user's time next to them. Rather like a
spreadsheet would do it.

Is this remotely possible for a beginning HTML programmer? I mainly use
Nvu to create my pages.

Philip
 
Reply With Quote
 
 
 
 
The Other Guy
Guest
Posts: n/a
 
      01-02-2007
Philip wrote:
> Is there an HTML function that can check the time in the computer it's
> running on, and output a result reflecting the difference between that
> time and NZ Standard, or Summer, time?


HTML does not have functions, it only describes the layout of a page.

You would need to use JavaScript to do this, but I'd favour just
specifying the times in GMT.

The Other Guy
 
Reply With Quote
 
 
 
 
Philip
Guest
Posts: n/a
 
      01-02-2007
The Other Guy wrote:
> Philip wrote:
>> Is there an HTML function that can check the time in the computer it's
>> running on, and output a result reflecting the difference between that
>> time and NZ Standard, or Summer, time?

>
> HTML does not have functions, it only describes the layout of a page.
>
> You would need to use JavaScript to do this, but I'd favour just
> specifying the times in GMT.
>
> The Other Guy


Such is my ignorance. I take your point about GMT (or UTC) but I I'm not
sure all my potential listeners (or even either of thhem) will be able
to make the leap from Zulu time to whatever their local clocks say.

So no I need to find out about programming in Java. This could be more
or less fun.

Philip
 
Reply With Quote
 
Fred Dagg
Guest
Posts: n/a
 
      01-02-2007
On Tue, 02 Jan 2007 14:03:59 +1300, Philip <(E-Mail Removed)>
exclaimed:

>Is there an HTML function that can check the time in the computer it's
>running on, and output a result reflecting the difference between that
>time and NZ Standard, or Summer, time?
>
>I want to put up a schdule for my radio stations, and be able to say to
>people that might look at it from outside NZ, something like:
>
>All times are n hours ahead of (or behind) (name of user's time zone)
>
>So a user in Queensland might see:
>
>Quensland time is three hours behind NZ time.
>
>Even nicer would be to convert the NZ time listings, which are in a
>simple table, to show the local user's time next to them. Rather like a
>spreadsheet would do it.
>
>Is this remotely possible for a beginning HTML programmer? I mainly use
>Nvu to create my pages.
>
>Philip


You need to do it in Javascript. Most users (>95%) have JS enabled,
but some may not, but that's a fact of life. There are far worse
things that wont work for them, from other badly designed pages (the
key is to not have anything essential rely on Javascript. eg. a hover
button is cool, but make sure it still works, albeit without the
effect, with JS turned off).

Anyway, check out the JS on this page for a working example:

http://www.shaps.hawaii.edu/whattime.html
http://www.shaps.hawaii.edu/times.js
 
Reply With Quote
 
Shane
Guest
Posts: n/a
 
      01-02-2007
Philip wrote:

> The Other Guy wrote:
>> Philip wrote:
>>> Is there an HTML function that can check the time in the computer it's
>>> running on, and output a result reflecting the difference between that
>>> time and NZ Standard, or Summer, time?

>>
>> HTML does not have functions, it only describes the layout of a page.
>>
>> You would need to use JavaScript to do this, but I'd favour just
>> specifying the times in GMT.
>>
>> The Other Guy

>
> Such is my ignorance. I take your point about GMT (or UTC) but I I'm not
> sure all my potential listeners (or even either of thhem) will be able
> to make the leap from Zulu time to whatever their local clocks say.
>
> So no I need to find out about programming in Java. This could be more
> or less fun.
>
> Philip


Its javascript, not Java
And, because I wanted to know how to do it myself I had a google round and
got this

http://www.irt.org/script/785.htm
(I'll post the lot so I can come back and read it if I need to)
Q785 How do I pass the client's local time to a server side process?

Either using a form submission:

<form name="myForm">
<input type="hidden" name="myTime" value="">
</form>

<script language="JavaScript"><!--
function padout(number) { return (number < 10) ? '0' + number : number; }

var today = new Date();

document.myForm.myTime = escape(padout(today.getHours()) + ':' +
padout(today.getMinutes()) + ':' + padout(today.getSeconds()));
//--></script>

Or as part of an image load request:

<script language="JavaScript"><!--
function padout(number) { return (number < 10) ? '0' + number : number; }

var today = new Date();

document.write('<img src="program.cgi?' + padout(today.getHours()) + ':' +
padout(today.getMinutes()) + ':' + padout(today.getSeconds()) + '"
width="1" height="1">');
//--></script>


Once you have their date you can calculate the diff between that and
localtime
HTH
--
Joey Mousepad: He's flashing his cash loaf again.
Don-Bot: How may times is that? Two or three?
Clamps: Three.
Don-Bot: All right. That's the necessary number of times. That scab is gonna
have a little 'on the job accident'.
Joey Mousepad: With all due respect Don-Bot, I don't think we should rely on
an accident happening. Let's kill him ourselves.

blog: http://shanes.dyndns.org

 
Reply With Quote
 
Dianthus Mimulus
Guest
Posts: n/a
 
      01-02-2007
On Tue, 02 Jan 2007 15:15:21 +1300, Philip wrote:

> Such is my ignorance. I take your point about GMT (or UTC) but I I'm not
> sure all my potential listeners (or even either of thhem) will be able
> to make the leap from Zulu time to whatever their local clocks say.


Given that most USA sites only specify times according to their local time
zones, you would be doing better than most if you included a simple page
that lists the different time zones with their differences between NZ time
and every other time zone.


--
Dianthus Mimulus

MS Windows Vista - broken by design
http://www.cs.auckland.ac.nz/~pgut00...vista_cost.txt
 
Reply With Quote
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      01-02-2007
In message <4599af7f$(E-Mail Removed)>, Philip wrote:

> Is there an HTML function that can check the time in the computer it's
> running on, and output a result reflecting the difference between that
> time and NZ Standard, or Summer, time?


First of all, you're going to need to embed some JavaScript in the Web page
in order to access the user's local time information.

Unfortunately, that's not enough. Look at my JavaScript documentation for
the "Date" object, there's no way I can see to access local time
information for an arbitrary time zone (i.e. NZ), only for the user's local
time zone.

So you're going to need to send the user's local time information back to
the Web server, which if it is running a *nix-type system will have full
access to all the world's timezone information, where you can compute the
appropriate difference and display it back to the user.
 
Reply With Quote
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      01-02-2007
In message <end34j$q5m$(E-Mail Removed)>, Lawrence D'Oliveiro wrote:

> In message <4599af7f$(E-Mail Removed)>, Philip wrote:
>
>> Is there an HTML function that can check the time in the computer it's
>> running on, and output a result reflecting the difference between that
>> time and NZ Standard, or Summer, time?

>
> First of all, you're going to need to embed some JavaScript in the Web
> page in order to access the user's local time information.
>
> Unfortunately, that's not enough. Look at my JavaScript documentation for
> the "Date" object, there's no way I can see to access local time
> information for an arbitrary time zone (i.e. NZ), only for the user's
> local time zone.
>
> So you're going to need to send the user's local time information back to
> the Web server, which if it is running a *nix-type system will have full
> access to all the world's timezone information, where you can compute the
> appropriate difference and display it back to the user.


Let me amend that. You can of course send the current NZ timezone offset
from UTC in the initial Web page, inserted as a "constant" in the
JavaScript code. That code can then get the user's local time zone, do the
calculation and display the result directly. No need for a second hit on
the Web server.
 
Reply With Quote
 
Aaron Lawrence
Guest
Posts: n/a
 
      01-02-2007
On a pleasant day while strolling in nz.comp, a person by the name of
Philip exclaimed:
> Is there an HTML function that can check the time in the computer it's
> running on, and output a result reflecting the difference between that
> time and NZ Standard, or Summer, time?


Using Javascript you can do this. Have a look at the source on my page:
http://integration.co.nz/ITLMail.htm

Note that the offset to NZ times are hard coded into the page (to avoid
server dependencies) and we have to adjust it when daylight saving comes
and goes.

If the user has Javascript disabled, of course this won't work.

--
aaronl at consultant dot com
For every expert, there is an equal and
opposite expert. - Arthur C. Clarke
 
Reply With Quote
 
Lawrence D'Oliveiro
Guest
Posts: n/a
 
      01-03-2007
In message <(E-Mail Removed)> , Aaron Lawrence
wrote:

> On a pleasant day while strolling in nz.comp, a person by the name of
> Philip exclaimed:
>> Is there an HTML function that can check the time in the computer it's
>> running on, and output a result reflecting the difference between that
>> time and NZ Standard, or Summer, time?

>
> Using Javascript you can do this. Have a look at the source on my page:
> http://integration.co.nz/ITLMail.htm
>
> Note that the offset to NZ times are hard coded into the page (to avoid
> server dependencies) and we have to adjust it when daylight saving comes
> and goes.


A more automatic technique would be to have the page dynamically generated
by a script that queries the current NZ daylight saving offset and inserts
it into the page as a JavaScript assignment at the appropriate place.
 
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
firefox html, my downloaded html and firebug html different? Adam Akhtar Ruby 9 08-16-2008 07:55 PM
How do I identify word<html><html>other word? Laura Perl 1 06-04-2004 11:32 PM
regexp question + html::parser question on the side boris bass Perl Misc 4 09-27-2003 02:24 AM
how to redirect to a frames-based html page and load the right html when coming from an ASP.NET page Mark Kamoski ASP .Net 1 08-13-2003 05:51 AM
How to use HTML::Parser to remove HTML tags and print result Mitchua Perl 1 07-15-2003 02:02 PM



Advertisments