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. General Programming
  3. C#
  4. label update/get system time

label update/get system time

Scheduled Pinned Locked Moved C#
questionannouncement
8 Posts 7 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.
  • R Offline
    R Offline
    rzvme
    wrote on last edited by
    #1

    i want a label to show the current system time? is there a method/property i can use to get the system time??

    rzvme

    Mircea PuiuM B X V M 5 Replies Last reply
    0
    • R rzvme

      i want a label to show the current system time? is there a method/property i can use to get the system time??

      rzvme

      Mircea PuiuM Offline
      Mircea PuiuM Offline
      Mircea Puiu
      wrote on last edited by
      #2

      DateTime.Now

      SkyWalker

      1 Reply Last reply
      0
      • R rzvme

        i want a label to show the current system time? is there a method/property i can use to get the system time??

        rzvme

        B Offline
        B Offline
        blue_arc
        wrote on last edited by
        #3

        lblTime.Text=DateTime.Now.ToString(); if u want this clock to tiking up... then u need to put some javascript...

        1 Reply Last reply
        0
        • R rzvme

          i want a label to show the current system time? is there a method/property i can use to get the system time??

          rzvme

          X Offline
          X Offline
          xstoneheartx
          wrote on last edited by
          #4

          you can use System.DateTime.Now

          1 Reply Last reply
          0
          • R rzvme

            i want a label to show the current system time? is there a method/property i can use to get the system time??

            rzvme

            V Offline
            V Offline
            V 0
            wrote on last edited by
            #5

            Call this lblTime.Text=DateTime.Now.ToString(); in a loop.

            V. I found a living worth working for, but haven't found work worth living for.

            L 1 Reply Last reply
            0
            • R rzvme

              i want a label to show the current system time? is there a method/property i can use to get the system time??

              rzvme

              M Offline
              M Offline
              MrEyes
              wrote on last edited by
              #6

              As already suggested you can use DateTime.Now.ToString(...formatting options...) to assign a value to the label. However this will only assigned the date time when the code is actually executed. I read your post as wanting it to display the current time. IMHO I would create a timer that ticks every second (or minute depending on what your clock displays) the tick event would then update the label value with the new DateTime.Now

              1 Reply Last reply
              0
              • V V 0

                Call this lblTime.Text=DateTime.Now.ToString(); in a loop.

                V. I found a living worth working for, but haven't found work worth living for.

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                Use 100% of CPU to change a string every second or so ? I would rather recommend a System.Windows.Forms.Timer to periodically update the label... :)

                Luc Pattyn

                V 1 Reply Last reply
                0
                • L Luc Pattyn

                  Use 100% of CPU to change a string every second or so ? I would rather recommend a System.Windows.Forms.Timer to periodically update the label... :)

                  Luc Pattyn

                  V Offline
                  V Offline
                  V 0
                  wrote on last edited by
                  #8

                  As a matter of fact, that was what I had in mind, but I didn't feel like explaining Timers... :-D.

                  V.
                  Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

                  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