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

insert time

Scheduled Pinned Locked Moved C#
question
13 Posts 6 Posters 1 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.
  • M mjawadkhatri

    Hi. i want 2 show time 24 hour how i can??

    S Offline
    S Offline
    SeMartens
    wrote on last edited by
    #2

    Hi, did you tried this: DateTime.Now.ToString("HH:mm:ss") ? Regards Sebastian P.S.: Please don't shout next time...

    It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

    M 1 Reply Last reply
    0
    • S SeMartens

      Hi, did you tried this: DateTime.Now.ToString("HH:mm:ss") ? Regards Sebastian P.S.: Please don't shout next time...

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      M Offline
      M Offline
      mjawadkhatri
      wrote on last edited by
      #3

      yes i tired this bt it show 12 hour after 12 am show 1 pm bt i want 13:00.

      S K 2 Replies Last reply
      0
      • M mjawadkhatri

        yes i tired this bt it show 12 hour after 12 am show 1 pm bt i want 13:00.

        S Offline
        S Offline
        SeMartens
        wrote on last edited by
        #4

        Okay, now I need more information. What are you doing exactly? Could you post a bit of your code?

        It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

        M 1 Reply Last reply
        0
        • S SeMartens

          Okay, now I need more information. What are you doing exactly? Could you post a bit of your code?

          It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

          M Offline
          M Offline
          mjawadkhatri
          wrote on last edited by
          #5

          this is my coding InitializeComponent(); { timer.Tick += new EventHandler(timer1_Tick); timer.Interval = (1000) * (1); timer.Enabled = true; timer.Start(); } private void timer1_Tick(object sender, EventArgs e) { DateTime dt = DateTime.Now; Time.Text = dt.ToString("hh:mm:ss"); }

          S 1 Reply Last reply
          0
          • M mjawadkhatri

            this is my coding InitializeComponent(); { timer.Tick += new EventHandler(timer1_Tick); timer.Interval = (1000) * (1); timer.Enabled = true; timer.Start(); } private void timer1_Tick(object sender, EventArgs e) { DateTime dt = DateTime.Now; Time.Text = dt.ToString("hh:mm:ss"); }

            S Offline
            S Offline
            SeMartens
            wrote on last edited by
            #6

            As said before: You have to use ToString("HH:mm:ss"). The format-string is case-sensitive. Uppercase H means 24-hour format.

            It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

            M 1 Reply Last reply
            0
            • S SeMartens

              As said before: You have to use ToString("HH:mm:ss"). The format-string is case-sensitive. Uppercase H means 24-hour format.

              It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

              M Offline
              M Offline
              mjawadkhatri
              wrote on last edited by
              #7

              thanks alot sir.

              1 Reply Last reply
              0
              • M mjawadkhatri

                yes i tired this bt it show 12 hour after 12 am show 1 pm bt i want 13:00.

                K Offline
                K Offline
                King Julien
                wrote on last edited by
                #8

                No way!!!! it is working and it should work!!! I am using the same format for several years now!!! no problem yet!!

                Have a Happy Coding.....

                C 1 Reply Last reply
                0
                • K King Julien

                  No way!!!! it is working and it should work!!! I am using the same format for several years now!!! no problem yet!!

                  Have a Happy Coding.....

                  C Offline
                  C Offline
                  Calla
                  wrote on last edited by
                  #9

                  Yes way - HH:mm:ss will not produce the same result as hh:mm:ss if it's past one o'clock.

                  K 1 Reply Last reply
                  0
                  • C Calla

                    Yes way - HH:mm:ss will not produce the same result as hh:mm:ss if it's past one o'clock.

                    K Offline
                    K Offline
                    King Julien
                    wrote on last edited by
                    #10

                    My reply was for the message posted by SeMartens. it clearly says "HH:mm:ss" ofcourse there are several ways that it can produce wrong results if you supply wrong formats like hh:mm:ss... HH:MM:ss ---------> which will give hours-months-seconds instead of minutes HH:mm:ss tt ------> which will give 24 hours-minutes-seconds Am/Pm hh:mm:SS ---------> will give hours-minutes-string "SS" and so on......

                    Have a Happy Coding.....

                    C 1 Reply Last reply
                    0
                    • K King Julien

                      My reply was for the message posted by SeMartens. it clearly says "HH:mm:ss" ofcourse there are several ways that it can produce wrong results if you supply wrong formats like hh:mm:ss... HH:MM:ss ---------> which will give hours-months-seconds instead of minutes HH:mm:ss tt ------> which will give 24 hours-minutes-seconds Am/Pm hh:mm:SS ---------> will give hours-minutes-string "SS" and so on......

                      Have a Happy Coding.....

                      C Offline
                      C Offline
                      Calla
                      wrote on last edited by
                      #11

                      Guess I missed the irony then..

                      1 Reply Last reply
                      0
                      • M mjawadkhatri

                        Hi. i want 2 show time 24 hour how i can??

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

                        That is all available in the documentation. Don't be lazy. :^)

                        Luc Pattyn [Forum Guidelines] [My Articles]


                        The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


                        1 Reply Last reply
                        0
                        • M mjawadkhatri

                          Hi. i want 2 show time 24 hour how i can??

                          M Offline
                          M Offline
                          morsanu
                          wrote on last edited by
                          #13

                          Using String.Format with "HH" - The hour, using a 24-hour clock from 00 to 23. More formats & examples here.

                          Who are you and why should I care?

                          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