Solved

Retrieving the system time in MFC

Posted on 1997-09-27
1
3,512 Views
Last Modified: 2013-11-19
How do I get the current system time into a member variable?
I tried using CTime::GetCurrentTime() but that returns the
elapsed time since Windows95 was started. I also checked out
the GetSystemTime() function but didn't understand how that works. The variable I'm using is a CTime variable.

// I want to store the current system time in this variable
CTime esDate;
     

0
Comment
Question by:imf
1 Comment
 
LVL 4

Accepted Solution

by:
davmarc earned 50 total points
ID: 1307049
No, you did it right.
CTime::GetSystemTime() internally calls the time() function of the run-time library, which in turn returns the current system time. It does return a value in seconds, but that's what it reads from the computer clock, not the amount of time elapsed since the start-up. Check the documentation and the MFC source files if you don't believe me.

So your code will look like:
CTime esDate = CTime::GetCurrentTime();

Davide Marcato.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question