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. Need To Convert Time

Need To Convert Time

Scheduled Pinned Locked Moved C#
8 Posts 5 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
    Rahul DSG
    wrote on last edited by
    #1

    hello... i am working in a web application .i need to convert the time like... 5.00PM To 1700 6.10PM To 1810 12.00PM TO 2400 etc... if there is any funtion that convert aal the time to thi format..and if not then tell me how could I do this... Thanks in Advance

    D P J 3 Replies Last reply
    0
    • R Rahul DSG

      hello... i am working in a web application .i need to convert the time like... 5.00PM To 1700 6.10PM To 1810 12.00PM TO 2400 etc... if there is any funtion that convert aal the time to thi format..and if not then tell me how could I do this... Thanks in Advance

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      Something like this:

      public static string ConvertTimeString(string time)
      {
      return DateTime.ParseExact(
      time,
      "h.mmtt",
      CultureInfo.InvariantCulture).ToString("HHmm");
      }

      Dave
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
      Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
      Why are you using VB6? Do you hate yourself? (Christian Graus)

      1 Reply Last reply
      0
      • R Rahul DSG

        hello... i am working in a web application .i need to convert the time like... 5.00PM To 1700 6.10PM To 1810 12.00PM TO 2400 etc... if there is any funtion that convert aal the time to thi format..and if not then tell me how could I do this... Thanks in Advance

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        merahul wrote:

        12.00PM TO 2400

        What? That's not right. Are you talking about user input? Why not have the user enter the data in the format you require?

        1 Reply Last reply
        0
        • R Rahul DSG

          hello... i am working in a web application .i need to convert the time like... 5.00PM To 1700 6.10PM To 1810 12.00PM TO 2400 etc... if there is any funtion that convert aal the time to thi format..and if not then tell me how could I do this... Thanks in Advance

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #4

          merahul wrote:

          12.00PM TO 2400

          12PM is 12:00 12AM is 00:00 there is no 24:00 in 24h time

          L P 2 Replies Last reply
          0
          • J J4amieC

            merahul wrote:

            12.00PM TO 2400

            12PM is 12:00 12AM is 00:00 there is no 24:00 in 24h time

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

            J4amieC wrote:

            there is no 24:00 in 24h time

            that is debatable[^]. :)

            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.


            J 1 Reply Last reply
            0
            • J J4amieC

              merahul wrote:

              12.00PM TO 2400

              12PM is 12:00 12AM is 00:00 there is no 24:00 in 24h time

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              J4amieC wrote:

              there is no 24:00 in 24h time

              There is in ISO 8601 (but I don't see why anyone would specify it).

              1 Reply Last reply
              0
              • L Luc Pattyn

                J4amieC wrote:

                there is no 24:00 in 24h time

                that is debatable[^]. :)

                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.


                J Offline
                J Offline
                J4amieC
                wrote on last edited by
                #7

                They can debate all they want, but 24:00 makes no sense.

                P 1 Reply Last reply
                0
                • J J4amieC

                  They can debate all they want, but 24:00 makes no sense.

                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #8

                  It may have its uses, but I haven't needed it yet.

                  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