Current Time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JCO

    #1

    Current Time

    The function below should work, but I would like to know how to get the to
    display at a specific area on a website. Can sombody tell me how to make
    use of this function. I have it pasted in the right area of my website
    (head section) and I'm sure it is loading when the page loads, but not sure
    how to execute it.

    function getTime()
    {
    var tNow = new Date()
    return tNow.toLocaleTi meString()
    }

    Thanks



  • McKirahan

    #2
    Re: Current Time

    " JCO" <joliviero4@hot mail.com> wrote in message
    news:c7Wve.164$ Iv6.96@trnddc03 ...[color=blue]
    > The function below should work, but I would like to know how to get the to
    > display at a specific area on a website. Can sombody tell me how to make
    > use of this function. I have it pasted in the right area of my website
    > (head section) and I'm sure it is loading when the page loads, but not[/color]
    sure[color=blue]
    > how to execute it.
    >
    > function getTime()
    > {
    > var tNow = new Date()
    > return tNow.toLocaleTi meString()
    > }
    >
    > Thanks[/color]


    Will this help? Watch for word-wrap.

    <html>
    <head>
    <title>time_js. htm</title>
    <script type="text/javascript">
    function getTime() {
    var tNow = new Date();
    document.getEle mentById("time" ).innerHTML = tNow.toLocaleTi meString();
    }
    </script>
    </head>
    <body onload="getTime ()">
    <hr>
    <span id="time"></span>
    <hr>
    </body>
    </html>


    Comment

    • Evertjan.

      #3
      Re: Current Time

      McKirahan wrote on 27 jun 2005 in comp.lang.javas cript:
      [color=blue]
      > Will this help? Watch for word-wrap.
      >
      > <html>
      > <head>
      > <title>time_js. htm</title>
      > <script type="text/javascript">
      > function getTime() {
      > var tNow = new Date();
      > document.getEle mentById("time" ).innerHTML =
      > tNow.toLocaleTi meString();
      >}
      > </script>
      > </head>
      > <body onload="getTime ()">
      > <hr>
      > <span id="time"></span>
      > <hr>
      > </body>
      > </html>
      >[/color]

      Simplify to:

      <html>
      <head>
      <title>time_js. htm</title>
      </head>
      <body>
      <hr>
      <script type="text/javascript">
      document.write( new Date().toLocale TimeString());
      </script>
      <hr>
      </body>
      </html>


      --
      Evertjan.
      The Netherlands.
      (Replace all crosses with dots in my emailaddress)

      Comment

      • JCO

        #4
        Re: Current Time

        Yes this works perfect.
        Thanks so much.

        "McKirahan" <News@McKirahan .com> wrote in message
        news:TcGdnUkIs9 AZr13fRVn-pw@comcast.com. ..[color=blue]
        > " JCO" <joliviero4@hot mail.com> wrote in message
        > news:c7Wve.164$ Iv6.96@trnddc03 ...[color=green]
        > > The function below should work, but I would like to know how to get the[/color][/color]
        to[color=blue][color=green]
        > > display at a specific area on a website. Can sombody tell me how to[/color][/color]
        make[color=blue][color=green]
        > > use of this function. I have it pasted in the right area of my website
        > > (head section) and I'm sure it is loading when the page loads, but not[/color]
        > sure[color=green]
        > > how to execute it.
        > >
        > > function getTime()
        > > {
        > > var tNow = new Date()
        > > return tNow.toLocaleTi meString()
        > > }
        > >
        > > Thanks[/color]
        >
        >
        > Will this help? Watch for word-wrap.
        >
        > <html>
        > <head>
        > <title>time_js. htm</title>
        > <script type="text/javascript">
        > function getTime() {
        > var tNow = new Date();
        > document.getEle mentById("time" ).innerHTML = tNow.toLocaleTi meString();
        > }
        > </script>
        > </head>
        > <body onload="getTime ()">
        > <hr>
        > <span id="time"></span>
        > <hr>
        > </body>
        > </html>
        >
        >[/color]


        Comment

        • Dr John Stockton

          #5
          Re: Current Time

          JRS: In article <TcGdnUkIs9AZr1 3fRVn-pw@comcast.com> , dated Mon, 27 Jun
          2005 12:10:25, seen in news:comp.lang. javascript, McKirahan
          <News@McKirahan .com> posted :
          [color=blue]
          >function getTime() {
          > var tNow = new Date();
          > document.getEle mentById("time" ).innerHTML = tNow.toLocaleTi meString();
          >}[/color]

          Method toLocaleTimeStr ing, though in ECMA-262, seems to be comparatively
          recent; getElementById is also recent; the OP should be warned that your
          code will not work in all browsers.

          Since getTime is a method of the Date object, it seems unwise to re-use
          that identifier for a distinct purpose.

          The OP should note that "Locale" forms are not necessarily correctly
          localised in all systems, and some may be ambiguous. IMHO, it's better
          to code an unambiguous ISO 8601 form; no-one can misunderstand it, and
          it annoys the rednecks.

          Does anyone know if a Web page listing the versions at which the more
          recent Date Object Methods were introduced in various browsers?

          --
          © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
          <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
          <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
          <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

          Comment

          Working...