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 / C++ / MFC
  4. conversion of date and time to string [modified]

conversion of date and time to string [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 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.
  • A Offline
    A Offline
    AmbiguousName
    wrote on last edited by
    #1

    hello guys...i did not inted to confuse all of you. I want to show the system time in a messaagebox and im using the following code

      SYSTEMTIME st;
      GetLocalTime(&st);
    

    now as stated earlier, i want to show it in a messagebox thus need to convert it to string, how can I do that??

    modified on Tuesday, September 14, 2010 8:14 AM

    C _ C L D 6 Replies Last reply
    0
    • A AmbiguousName

      hello guys...i did not inted to confuse all of you. I want to show the system time in a messaagebox and im using the following code

        SYSTEMTIME st;
        GetLocalTime(&st);
      

      now as stated earlier, i want to show it in a messagebox thus need to convert it to string, how can I do that??

      modified on Tuesday, September 14, 2010 8:14 AM

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      How is the date and time represented? If using COleDateTime, you can use its Format method. Otherwise use sprintf_s or swprintf_s to format the date and time into a string. You can also use CString::Format instead.

      «_Superman_»
      I love work. It gives me something to do between weekends.

      Microsoft MVP (Visual C++)

      Polymorphism in C

      1 Reply Last reply
      0
      • A AmbiguousName

        hello guys...i did not inted to confuse all of you. I want to show the system time in a messaagebox and im using the following code

          SYSTEMTIME st;
          GetLocalTime(&st);
        

        now as stated earlier, i want to show it in a messagebox thus need to convert it to string, how can I do that??

        modified on Tuesday, September 14, 2010 8:14 AM

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        What do you mean by "date and time" exactly ? You have different types of objects that can represent date and time, so what are you using ? Take a look for instance at COLEDateTime[^].

        Cédric Moonen Software developer
        Charting control [v3.0] OpenGL game tutorial in C++

        1 Reply Last reply
        0
        • A AmbiguousName

          hello guys...i did not inted to confuse all of you. I want to show the system time in a messaagebox and im using the following code

            SYSTEMTIME st;
            GetLocalTime(&st);
          

          now as stated earlier, i want to show it in a messagebox thus need to convert it to string, how can I do that??

          modified on Tuesday, September 14, 2010 8:14 AM

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          If you're using ATL/MFC COleDateTime then have a look at Format method. If you're instead using Win32 then read about strftime function. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          1 Reply Last reply
          0
          • A AmbiguousName

            hello guys...i did not inted to confuse all of you. I want to show the system time in a messaagebox and im using the following code

              SYSTEMTIME st;
              GetLocalTime(&st);
            

            now as stated earlier, i want to show it in a messagebox thus need to convert it to string, how can I do that??

            modified on Tuesday, September 14, 2010 8:14 AM

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

            if there are many if's in the replies, maybe you should provide more information to start with. :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

            1 Reply Last reply
            0
            • A AmbiguousName

              hello guys...i did not inted to confuse all of you. I want to show the system time in a messaagebox and im using the following code

                SYSTEMTIME st;
                GetLocalTime(&st);
              

              now as stated earlier, i want to show it in a messagebox thus need to convert it to string, how can I do that??

              modified on Tuesday, September 14, 2010 8:14 AM

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              overloaded Name wrote:

              ...thus need to convert it to string, how can I do that??

              In addition to the others, there's also asctime() and ctime().

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "Man who follows car will be exhausted." - Confucius

              1 Reply Last reply
              0
              • A AmbiguousName

                hello guys...i did not inted to confuse all of you. I want to show the system time in a messaagebox and im using the following code

                  SYSTEMTIME st;
                  GetLocalTime(&st);
                

                now as stated earlier, i want to show it in a messagebox thus need to convert it to string, how can I do that??

                modified on Tuesday, September 14, 2010 8:14 AM

                S Offline
                S Offline
                Shivanand Gupta
                wrote on last edited by
                #7

                in mfc use COleDateTime class and after that Format method in win 32 use sprintf function

                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