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. how to get the date

how to get the date

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 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.
  • M Offline
    M Offline
    mr2003
    wrote on last edited by
    #1

    Hi, I would like see if I can get the system date in a few lines of code? any ideas? Thanks Ehsan Behboudi

    C H A J 4 Replies Last reply
    0
    • M mr2003

      Hi, I would like see if I can get the system date in a few lines of code? any ideas? Thanks Ehsan Behboudi

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      look up time_t in the MSDN. Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

      1 Reply Last reply
      0
      • M mr2003

        Hi, I would like see if I can get the system date in a few lines of code? any ideas? Thanks Ehsan Behboudi

        H Offline
        H Offline
        Hin Jang
        wrote on last edited by
        #3

        #include time_t now; struct tm *newtime; char todaysDate[128]; // get the number of seconds since January 1, 1970 time(&now); // get the current system date newtime = localtime(&now); todaysDate = asctime(newtime));

        1 Reply Last reply
        0
        • M mr2003

          Hi, I would like see if I can get the system date in a few lines of code? any ideas? Thanks Ehsan Behboudi

          A Offline
          A Offline
          Alvaro Mendez
          wrote on last edited by
          #4

          If using MFC,

          COleDateTime dt = COleDateTime::GetCurrentTime();

          Regards, Alvaro


          He who laughs last, thinks slowest.

          1 Reply Last reply
          0
          • M mr2003

            Hi, I would like see if I can get the system date in a few lines of code? any ideas? Thanks Ehsan Behboudi

            J Offline
            J Offline
            Jijo Raj
            wrote on last edited by
            #5

            Its very Simple. SYSTEMTIME systime; GetLocalTime ( &systime ); then systime.wDay is the Day systime.wMonth is the month and systime.wYear is the year. itn't it cool ? ;) Best Regards, Jijo. The nice thing about standards is that there are so many of them to choose from.

            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