An HTML question

Discussion in 'NZ Computing' started by Philip, Jan 2, 2007.

  1. Philip

    Philip Guest

    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
    Philip, Jan 2, 2007
    #1
    1. Advertising

  2. 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
    The Other Guy, Jan 2, 2007
    #2
    1. Advertising

  3. Philip

    Philip Guest

    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
    Philip, Jan 2, 2007
    #3
  4. Philip

    Fred Dagg Guest

    On Tue, 02 Jan 2007 14:03:59 +1300, 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?
    >
    >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
    Fred Dagg, Jan 2, 2007
    #4
  5. Philip

    Shane Guest

    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
    Shane, Jan 2, 2007
    #5
  6. 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/~pgut001/pubs/vista_cost.txt
    Dianthus Mimulus, Jan 2, 2007
    #6
  7. In message <4599af7f$>, 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.
    Lawrence D'Oliveiro, Jan 2, 2007
    #7
  8. In message <end34j$q5m$>, Lawrence D'Oliveiro wrote:

    > In message <4599af7f$>, 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.
    Lawrence D'Oliveiro, Jan 2, 2007
    #8
  9. 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
    Aaron Lawrence, Jan 2, 2007
    #9
  10. In message <>, 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.
    Lawrence D'Oliveiro, Jan 3, 2007
    #10
  11. Philip

    jasen Guest

    On 2007-01-02, 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?


    NO. html doesn't have functions.

    with a little scripting at both ends though something like that could be
    done.
    (you could even update the times to match their local zone)


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


    to make this work you really need server side scripting otherwise you're
    relying on the user of the remote computer having the correct tiome
    settings.

    > Philip



    --

    Bye.
    Jasen
    jasen, Jan 3, 2007
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris C.

    Html/Java Question

    Chris C., Jun 25, 2003, in forum: Computer Support
    Replies:
    2
    Views:
    433
    Hywel Jenkins
    Jun 26, 2003
  2. Edison Carter

    HTML question concerning spaces in filename/directory

    Edison Carter, Sep 30, 2003, in forum: Computer Support
    Replies:
    3
    Views:
    630
    Brian H¹©
    Sep 30, 2003
  3. Martin Eden

    Vadidating HTML question

    Martin Eden, Dec 13, 2003, in forum: Computer Support
    Replies:
    11
    Views:
    574
  4. Steve Freides

    HTML question

    Steve Freides, Jan 18, 2004, in forum: Computer Support
    Replies:
    4
    Views:
    444
    Tina - AffordableHOST.com
    Jan 18, 2004
  5. Monima
    Replies:
    0
    Views:
    1,787
    Monima
    Dec 14, 2010
Loading...

Share This Page