Javascript DATE&TIME HTML

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

    #1

    Javascript DATE&TIME HTML

    can someone tell me how to make this first one work??, located here:


    This second one, well, dreamweaver eats the code, removes the code as bad.
    Any help here? Please? 2nd located here:
    http://www.dynamicdrive.com/dynamicindex6/clock3.htm
    Appreciated,
    M.E.


  • McKirahan

    #2
    Re: Javascript DATE&TIME HTML

    "ME" <me@mine.com> wrote in message news:V9ydnfmbh5 OYq6TcRVn-tg@eatel.net...[color=blue]
    > can someone tell me how to make this first one work??, located here:
    >[/color]


    What doesn't work?

    <html>
    <head>
    <title>ShowDate Time.htm</title>
    <script type="text/javascript">
    var showDateShort = 1;
    var showDate= 2;
    var showDateTime= 3;
    var showTime= 4;

    function ShowDateTime(da teStyle) {
    var today = new Date();
    var dStr = "";
    switch (dateStyle) {
    case showDateShort:
    dStr = today.toDateStr ing();
    break;
    case showDateTime:
    dStr = today.toLocaleS tring();
    break;
    case showTime:
    dStr = today.toLocaleT imeString();
    break;
    case showDate:
    default:
    dStr = today.toLocaleD ateString();
    break;
    }
    document.write( dStr);
    }
    </script>
    </head>
    <body>
    <script type="text/javascript">
    ShowDateTime(sh owDateShort);
    document.write( "<br>");
    ShowDateTime(sh owDate);
    document.write( "<br>");
    ShowDateTime(sh owDateTime);
    document.write( "<br>");
    ShowDateTime(sh owTime);
    </script>
    </body>
    </html>
    [color=blue]
    >
    > This second one, well, dreamweaver eats the code, removes the code as bad.
    > Any help here? Please? 2nd located here:
    > http://www.dynamicdrive.com/dynamicindex6/clock3.htm[/color]

    Again, what doesn't work?

    <html>
    <head>
    <title>DynaDate Time.htm</title>
    <script type="text/javascript">
    /*
    Live Date Script-
    © Dynamic Drive (www.dynamicdrive.com)
    For full source code, installation instructions, 100's more DHTML scripts,
    and Terms Of Use,
    visit http://www.dynamicdrive.com
    */

    var dayarray=new
    Array("Sunday", "Monday","Tuesd ay","Wednesday" ,"Thursday","Fr iday","Saturday "
    );
    var montharray=new
    Array("January" ,"February","Ma rch","April","M ay","June","Jul y","August","Se p
    tember","Octobe r","November"," December");

    function getthedate() {
    var mydate = new Date();
    var year = mydate.getYear( );
    if (year < 1000) year+=1900;
    var day = mydate.getDay() ;
    var month = mydate.getMonth ();
    var daym = mydate.getDate( );
    if (daym<10) daym = "0"+daym;
    var hours = mydate.getHours ();
    var minutes = mydate.getMinut es();
    var seconds = mydate.getSecon ds();
    var dn = "AM";
    if (hours>=12) dn = "PM";
    if (hours>12) hours = hours-12;
    if (hours==0) hours = 12;
    if (minutes<=9) minutes = "0"+minutes ;
    if (seconds<=9) seconds = "0"+seconds ;
    // change font size here
    var cdate="<small>< font color='000000'
    face='Arial'><b >"+dayarray[day]+", "+montharra y[month]+" "+daym+", "+year+"
    "+hours+":"+min utes+":"+second s+" "+dn+"</b></font></small>"
    if (document.all)
    document.all.cl ock.innerHTML = cdate;
    else if (document.getEl ementById)
    document.getEle mentById("clock ").innerHTM L = cdate;
    else
    document.write( cdate);
    }

    if (!document.all && !document.getEl ementById) getthedate();

    function goforit() {
    if (document.all || document.getEle mentById)
    setInterval("ge tthedate()",100 0);
    }
    </script>
    </head>
    <body onLoad="goforit ()">
    <span id="clock"></span>
    </body>
    </html>
    [color=blue]
    > Appreciated,
    > M.E.
    >
    >[/color]

    Did you watch for word-wrap?


    Comment

    • ME

      #3
      Re: Javascript DATE&amp;TIME HTML

      The first one I do not know how to paste into the html page. The second,
      dreamweaver removes the <span tags everytime I open the html. Word Wrap?
      Like how?

      ME






      "McKirahan" <News@McKirahan .com> wrote in message
      news:bzb_c.3687 89$%_6.269826@a ttbi_s01...[color=blue]
      > "ME" <me@mine.com> wrote in message[/color]
      news:V9ydnfmbh5 OYq6TcRVn-tg@eatel.net...[color=blue][color=green]
      > > can someone tell me how to make this first one work??, located here:
      > >[/color]
      >[/color]
      http://javascript.about.com/library/...#examplesource[color=blue]
      >
      > What doesn't work?
      >
      > <html>
      > <head>
      > <title>ShowDate Time.htm</title>
      > <script type="text/javascript">
      > var showDateShort = 1;
      > var showDate= 2;
      > var showDateTime= 3;
      > var showTime= 4;
      >
      > function ShowDateTime(da teStyle) {
      > var today = new Date();
      > var dStr = "";
      > switch (dateStyle) {
      > case showDateShort:
      > dStr = today.toDateStr ing();
      > break;
      > case showDateTime:
      > dStr = today.toLocaleS tring();
      > break;
      > case showTime:
      > dStr = today.toLocaleT imeString();
      > break;
      > case showDate:
      > default:
      > dStr = today.toLocaleD ateString();
      > break;
      > }
      > document.write( dStr);
      > }
      > </script>
      > </head>
      > <body>
      > <script type="text/javascript">
      > ShowDateTime(sh owDateShort);
      > document.write( "<br>");
      > ShowDateTime(sh owDate);
      > document.write( "<br>");
      > ShowDateTime(sh owDateTime);
      > document.write( "<br>");
      > ShowDateTime(sh owTime);
      > </script>
      > </body>
      > </html>
      >[color=green]
      > >
      > > This second one, well, dreamweaver eats the code, removes the code as[/color][/color]
      bad.[color=blue][color=green]
      > > Any help here? Please? 2nd located here:
      > > http://www.dynamicdrive.com/dynamicindex6/clock3.htm[/color]
      >
      > Again, what doesn't work?
      >
      > <html>
      > <head>
      > <title>DynaDate Time.htm</title>
      > <script type="text/javascript">
      > /*
      > Live Date Script-
      > © Dynamic Drive (www.dynamicdrive.com)
      > For full source code, installation instructions, 100's more DHTML scripts,
      > and Terms Of Use,
      > visit http://www.dynamicdrive.com
      > */
      >
      > var dayarray=new
      >[/color]
      Array("Sunday", "Monday","Tuesd ay","Wednesday" ,"Thursday","Fr iday","Saturday "[color=blue]
      > );
      > var montharray=new
      >[/color]
      Array("January" ,"February","Ma rch","April","M ay","June","Jul y","August","Se p[color=blue]
      > tember","Octobe r","November"," December");
      >
      > function getthedate() {
      > var mydate = new Date();
      > var year = mydate.getYear( );
      > if (year < 1000) year+=1900;
      > var day = mydate.getDay() ;
      > var month = mydate.getMonth ();
      > var daym = mydate.getDate( );
      > if (daym<10) daym = "0"+daym;
      > var hours = mydate.getHours ();
      > var minutes = mydate.getMinut es();
      > var seconds = mydate.getSecon ds();
      > var dn = "AM";
      > if (hours>=12) dn = "PM";
      > if (hours>12) hours = hours-12;
      > if (hours==0) hours = 12;
      > if (minutes<=9) minutes = "0"+minutes ;
      > if (seconds<=9) seconds = "0"+seconds ;
      > // change font size here
      > var cdate="<small>< font color='000000'
      > face='Arial'><b >"+dayarray[day]+", "+montharra y[month]+" "+daym+",[/color]
      "+year+"[color=blue]
      > "+hours+":"+min utes+":"+second s+" "+dn+"</b></font></small>"
      > if (document.all)
      > document.all.cl ock.innerHTML = cdate;
      > else if (document.getEl ementById)
      > document.getEle mentById("clock ").innerHTM L = cdate;
      > else
      > document.write( cdate);
      > }
      >
      > if (!document.all && !document.getEl ementById) getthedate();
      >
      > function goforit() {
      > if (document.all || document.getEle mentById)
      > setInterval("ge tthedate()",100 0);
      > }
      > </script>
      > </head>
      > <body onLoad="goforit ()">
      > <span id="clock"></span>
      > </body>
      > </html>
      >[color=green]
      > > Appreciated,
      > > M.E.
      > >
      > >[/color]
      >
      > Did you watch for word-wrap?
      >
      >[/color]


      Comment

      • Andrew Thompson

        #4
        Re: Javascript DATE&amp;TIME HTML

        On Sat, 4 Sep 2004 13:49:18 -0500, ME wrote:
        [color=blue]
        > dreamweaver removes the <span tags everytime I open the html.[/color]

        Patient: "It hurts when I bang
        my head against the wall."

        Doctor: "Don't bang your head against
        the wall. That will be $130, pay the
        receptionist on the way out."

        --
        Andrew Thompson
        http://www.PhySci.org/ Open-source software suite
        http://www.PhySci.org/codes/ Web & IT Help
        http://www.1point1C.org/ Science & Technology

        Comment

        • Dr John Stockton

          #5
          Re: Javascript DATE&amp;TIME HTML

          JRS: In article <bzb_c.368789$% _6.269826@attbi _s01>, dated Sat, 4 Sep
          2004 04:32:08, seen in news:comp.lang. javascript, McKirahan
          <News@McKirahan .com> posted :
          [color=blue]
          > dStr = today.toLocaleT imeString();
          > dStr = today.toLocaleD ateString();[/color]

          Functions not available in all browsers. The presumed effect should be
          more widely available by a RegExp edit of today.toLocaleS tring() ;
          however, the format given is what the browser writers thought right for
          the locale, and may be misleading.

          [color=blue]
          > if (year < 1000) year+=1900;[/color]

          AIUI, does not work correctly on all systems. I hear that one or more
          systems return Year%100 for getYear.

          Use getFullYear if assumable as available; otherwise, a substitute using
          getYear and getTime is available and was presented here fairly recently
          - see also my js-date0.htm#gFY
          [color=blue]
          > if (daym<10) daym = "0"+daym;
          > if (minutes<=9) minutes = "0"+minutes ;
          > if (seconds<=9) seconds = "0"+seconds ;[/color]

          Better to use a function for this repeated code.

          [color=blue]
          >function goforit() {
          > if (document.all || document.getEle mentById)
          > setInterval("ge tthedate()",100 0);
          >}[/color]

          Will not show every second; easily fixed. Author needs to do some
          reading.

          By the way, the 12-hour clock should not be used on the Web; it is a
          mere American affectation. It should be used only for real-time
          analogue displays.

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

          • Ian Sedwell

            #6
            Re: Javascript DATE&amp;TIME HTML

            On 2004/09/04 16:57, in article xnSA1aBYXeOBFwK X@merlyn.demon. co.uk, "Dr
            John Stockton" <spam@merlyn.de mon.co.uk> wrote:
            [color=blue]
            > By the way, the 12-hour clock should not be used on the Web; it is a
            > mere American affectation. It should be used only for real-time
            > analogue displays.
            >[/color]

            Speaking as a mere Brit, this is a bit much John. The 12-hour and 24-hour
            clocks are more or less universally recognised everywhere you go in the
            world. Moreover, it is the 24-hour clock that is the affectation as a simple
            consideration of the expression of time in the English (and all other modern
            Indo-European) languages will confirm. Which perhaps explains why the
            12-hour clock is the one most people habitually prefer.

            The 24-hour clock in fact originated as a military device to avoid awkward
            and embarrassing moments like launching your part of the offensive 12 hours
            after (or before) the guy further up the line.

            You'll be telling us that "fall" is an Americanism for "autumn" next. What
            would Shakespeare think?

            "Neither my husband, nor the slave return'd
            That in such haste I sent to seek his master!
            Sure, Luciana, it is 14:00 hours."

            - Comedy of Errors, Act II, Scene I (American web version)

            Dr Ian Sedwell

            Comment

            • Dr John Stockton

              #7
              Re: Javascript DATE&amp;TIME HTML

              JRS: In article <BD62A928.CE1C% ian.sedwell@btc lick.com>, dated Mon, 6
              Sep 2004 22:52:32, seen in news:comp.lang. javascript, Ian Sedwell
              <ian.sedwell@bt click.com> posted :[color=blue]
              >On 2004/09/04 16:57, in article xnSA1aBYXeOBFwK X@merlyn.demon. co.uk, "Dr
              >John Stockton" <spam@merlyn.de mon.co.uk> wrote:
              >[color=green]
              >> By the way, the 12-hour clock should not be used on the Web; it is a
              >> mere American affectation. It should be used only for real-time
              >> analogue displays.
              >>[/color]
              >
              >Speaking as a mere Brit, this is a bit much John. The 12-hour and 24-hour
              >clocks are more or less universally recognised everywhere you go in the
              >world. Moreover, it is the 24-hour clock that is the affectation as a simple
              >consideratio n of the expression of time in the English (and all other modern
              >Indo-European) languages will confirm. Which perhaps explains why the
              >12-hour clock is the one most people habitually prefer.[/color]

              The 24-hour clock is simpler, and is understood everywhere; it is
              therefore better than the 12-hour one.

              The 12-hour clock is in fact also fairly well understood, though that
              will diminish as the proportion of digital to analogue timepieces
              increases (Yes, I know that there are 12-h digital ones; but, sundials
              apart, there are few 24-h analogue ones). But there is a greater risk
              of error on its use.

              24-hour times, with fixed-width fields, can be sorted as strings;
              12-hour ones need careful modification (js-date0.htm#TCp> or full
              conversion first.

              Getting the 24-hour clock to be considered the norm is a step on the way
              towards stamping out the traditional European D M Y and the ludicrous M
              D Y for dates and getting, for everyone, the full benefit of ISO 8601.

              [color=blue]
              >You'll be telling us that "fall" is an Americanism for "autumn" next. What
              >would Shakespeare think?[/color]

              It is an Americanism. The language of England has developed since
              Shakespeare's time. That of America has diverged.

              --
              © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
              Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
              PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
              Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

              Comment

              • Ian Sedwell

                #8
                Re: Javascript DATE&amp;TIME HTML

                On 2004/09/07 11:11, in article mRul4NDvlYPBFwi Y@merlyn.demon. co.uk, "Dr
                John Stockton" <spam@merlyn.de mon.co.uk> wrote:
                [color=blue]
                > JRS: In article <BD62A928.CE1C% ian.sedwell@btc lick.com>, dated Mon, 6
                > Sep 2004 22:52:32, seen in news:comp.lang. javascript, Ian Sedwell
                > <ian.sedwell@bt click.com> posted :[color=green]
                >> On 2004/09/04 16:57, in article xnSA1aBYXeOBFwK X@merlyn.demon. co.uk, "Dr
                >> John Stockton" <spam@merlyn.de mon.co.uk> wrote:
                >>[color=darkred]
                >>> By the way, the 12-hour clock should not be used on the Web; it is a
                >>> mere American affectation. It should be used only for real-time
                >>> analogue displays.
                >>>[/color]
                >>
                >> Speaking as a mere Brit, this is a bit much John. The 12-hour and 24-hour
                >> clocks are more or less universally recognised everywhere you go in the
                >> world. Moreover, it is the 24-hour clock that is the affectation as a simple
                >> consideration of the expression of time in the English (and all other modern
                >> Indo-European) languages will confirm. Which perhaps explains why the
                >> 12-hour clock is the one most people habitually prefer.[/color]
                >
                > The 24-hour clock is simpler, and is understood everywhere; it is
                > therefore better than the 12-hour one.[/color]

                Agreed, but that gives nobody the right to prescribe the one and proscribe
                the other. People habitually use the 12-hour clock. Listen to program times
                as they are announced on the TV, look at how English and other languages
                assiduously incorporate the 12-hour clock as their normal mode of temporal
                expression.[color=blue]
                >
                > The 12-hour clock is in fact also fairly well understood, though that
                > will diminish as the proportion of digital to analogue timepieces
                > increases (Yes, I know that there are 12-h digital ones; but, sundials
                > apart, there are few 24-h analogue ones). But there is a greater risk
                > of error on its use.
                >
                > 24-hour times, with fixed-width fields, can be sorted as strings;
                > 12-hour ones need careful modification (js-date0.htm#TCp> or full
                > conversion first.[/color]

                Agreed. So what's wrong with making things easy for the poor user and doing
                things the way they want for a change. It is a simple matter to convert a
                12-hour date string to a 24-hour one, perform whatever manipulations are
                required and change the result back to 12-hours. The user's happy, the
                programmer's happy and the machine gets to chew a few more CPU cycles. What
                the hell. People are important, not computers.
                [color=blue]
                >
                > Getting the 24-hour clock to be considered the norm is a step on the way
                > towards stamping out the traditional European D M Y and the ludicrous M
                > D Y for dates and getting, for everyone, the full benefit of ISO 8601.[/color]

                Completely agree.[color=blue]
                >
                >[color=green]
                >> You'll be telling us that "fall" is an Americanism for "autumn" next. What
                >> would Shakespeare think?[/color]
                >
                > It is an Americanism. The language of England has developed since
                > Shakespeare's time. That of America has diverged.
                >[/color]

                Sorry. It's not. It's actually from the Old Saxon "fallain", meaning to fall
                and was used to describe the change of season at the end of summer. It
                retained this usage through the related Old English word "feallan" and the
                Old Norse "falla". Its use persisted in Middle and early Modern English and
                was taken to America by the early settlers. It is a classic example of how
                many "Americanis ms" are in fact remnants of an older form of Modern English
                which we Brits have either dropped completely or now regard as archaic.

                All language develop and diverge. Even computer languages, though these are
                trivial by comparison. A quick glance through de Saussure will convince you
                that language is a continually changing thing. No one language is more
                primitive, or more sophisticated than any other; nor are any dialects within
                languages.

                Comment

                • Dr John Stockton

                  #9
                  Re: Javascript DATE&amp;TIME HTML

                  JRS: In article <BD63F0AB.CF15% ian.sedwell@btc lick.com>, dated Tue, 7
                  Sep 2004 22:09:53, seen in news:comp.lang. javascript, Ian Sedwell
                  <ian.sedwell@bt click.com> posted :[color=blue]
                  >On 2004/09/07 11:11, in article mRul4NDvlYPBFwi Y@merlyn.demon. co.uk, "Dr
                  >John Stockton" <spam@merlyn.de mon.co.uk> wrote:[/color]
                  [color=blue]
                  >Agreed. So what's wrong with making things easy for the poor user and doing
                  >things the way they want for a change. It is a simple matter to convert a
                  >12-hour date string to a 24-hour one, perform whatever manipulations are
                  >required and change the result back to 12-hours. The user's happy, the
                  >programmer's happy and the machine gets to chew a few more CPU cycles. What
                  >the hell. People are important, not computers.[/color]

                  It's not simple enough for some of those who post here.

                  [color=blue][color=green][color=darkred]
                  >>> You'll be telling us that "fall" is an Americanism for "autumn" next. What
                  >>> would Shakespeare think?[/color]
                  >>
                  >> It is an Americanism. The language of England has developed since
                  >> Shakespeare's time. That of America has diverged.
                  >>[/color]
                  >
                  >Sorry. It's not. It's actually from the Old Saxon "fallain", meaning to fall
                  >and was used to describe the change of season at the end of summer. It
                  >retained this usage through the related Old English word "feallan" and the
                  >Old Norse "falla". Its use persisted in Middle and early Modern English and
                  >was taken to America by the early settlers. It is a classic example of how
                  >many "Americanis ms" are in fact remnants of an older form of Modern English
                  >which we Brits have either dropped completely or now regard as archaic.
                  >
                  >All language develop and diverge. Even computer languages, though these are
                  >trivial by comparison. A quick glance through de Saussure will convince you
                  >that language is a continually changing thing. No one language is more
                  >primitive, or more sophisticated than any other; nor are any dialects within
                  >languages.[/color]

                  That's right. It's an Americanism, because they have retained it and we
                  have not. It's just not an original Americanism.

                  --
                  © John Stockton, Surrey, UK. ???@merlyn.demo n.co.uk Turnpike v4.00 MIME. ©
                  Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms, & links.

                  Food expiry ambiguities: <URL:http://www.merlyn.demo n.co.uk/date2k-3.htm#Food>

                  Comment

                  • Ian Sedwell

                    #10
                    Re: Javascript DATE&amp;TIME HTML

                    > That's right. It's an Americanism, because they have retained it and we[color=blue]
                    > have not. It's just not an original Americanism.
                    >[/color]


                    Oh man! You're priceless! LOL


                    Comment

                    Working...