Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Digital clock

Digital clock

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kavinnagarajan
    wrote on last edited by
    #1

    How to program to display clock time including seconds like digital clock in master page?

    S A 2 Replies Last reply
    0
    • K kavinnagarajan

      How to program to display clock time including seconds like digital clock in master page?

      S Offline
      S Offline
      Sun Rays
      wrote on last edited by
      #2

      Hi, you can check[^] this.

      Thanks, Sun Rays To get something you must have to try once. Rate answers if you like else reply me so can make it liked.... My Articles

      1 Reply Last reply
      0
      • K kavinnagarajan

        How to program to display clock time including seconds like digital clock in master page?

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        The better and simpliest solution I think, Create a Flash file of Digital Clock. embed it with asp.net page.

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article

        K 1 Reply Last reply
        0
        • A Abhijit Jana

          The better and simpliest solution I think, Create a Flash file of Digital Clock. embed it with asp.net page.

          Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article

          K Offline
          K Offline
          kavinnagarajan
          wrote on last edited by
          #4

          I need system date & time to be displayed in master page.

          A A 2 Replies Last reply
          0
          • K kavinnagarajan

            I need system date & time to be displayed in master page.

            A Offline
            A Offline
            Abhijit Jana
            wrote on last edited by
            #5

            Yes. Create a Flash Digital Clock and set it on master page ;)

            Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article

            1 Reply Last reply
            0
            • K kavinnagarajan

              I need system date & time to be displayed in master page.

              A Offline
              A Offline
              Abhishek Sur
              wrote on last edited by
              #6

              place the javascript function in your masterpage

              var clock;

              function stopClock(){
              clearTimeout(clock);
              }

              function yourClock(){
              var nd = new Date();
              var h, m;
              var s;
              var time = " ";
              h = nd.getHours();
              m = nd.getMinutes();
              s = nd.getSeconds();
              if (h <= 9) h = "0" + h;
              if (m <= 9) m = "0" + m;
              if (s <= 9) s = "0" + s;
              time += h + ":" + m + ":" + s;
              document.getElementbyId('yourclockbox').value = time;
              clock = setTimeout("yourClock()", 1000);
              }

              Now in body tag of your masterpage use : <BODY onLoad="yourClock()", onUnload="stopClock(); return true"> Place one div named yourclockbox in your page. Apply proper CSS. You are done... :thumbsup::thumbsup:

              Abhishek Sur


              My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

              **Don't forget to click "Good Answer" if you like to.

              K 1 Reply Last reply
              0
              • A Abhishek Sur

                place the javascript function in your masterpage

                var clock;

                function stopClock(){
                clearTimeout(clock);
                }

                function yourClock(){
                var nd = new Date();
                var h, m;
                var s;
                var time = " ";
                h = nd.getHours();
                m = nd.getMinutes();
                s = nd.getSeconds();
                if (h <= 9) h = "0" + h;
                if (m <= 9) m = "0" + m;
                if (s <= 9) s = "0" + s;
                time += h + ":" + m + ":" + s;
                document.getElementbyId('yourclockbox').value = time;
                clock = setTimeout("yourClock()", 1000);
                }

                Now in body tag of your masterpage use : <BODY onLoad="yourClock()", onUnload="stopClock(); return true"> Place one div named yourclockbox in your page. Apply proper CSS. You are done... :thumbsup::thumbsup:

                Abhishek Sur


                My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

                **Don't forget to click "Good Answer" if you like to.

                K Offline
                K Offline
                kavinnagarajan
                wrote on last edited by
                #7

                I used like this but its showing nothing.

                A 1 Reply Last reply
                0
                • K kavinnagarajan

                  I used like this but its showing nothing.

                  A Offline
                  A Offline
                  Abhishek Sur
                  wrote on last edited by
                  #8

                  Just a little modification required.Use the script below:

                  var clock;
                  
                  function stopClock(){
                      clearTimeout(clock);
                  }
                  
                  function yourClock(){
                    var nd = new Date();
                    var h, m;
                    var s;
                    var time = " ";
                    h = nd.getHours();
                    m = nd.getMinutes();
                    s = nd.getSeconds();
                    if (h <= 9) h = "0" + h;
                    if (m <= 9) m = "0" + m;
                    if (s <= 9) s = "0" + s;
                    time += h + ":" + m + ":" + s;
                    document.getElementById('yourclockbox').innerHTML = time;
                    clock = setTimeout("yourClock()", 1000);
                  }
                  

                  If you want to show the element inside a div use innerHTML rather than value. Label1 is also not declared. :rose::rose:

                  Abhishek Sur


                  My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

                  **Don't forget to click "Good Answer" if you like to.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups