Solved

Retrieving the system time in MFC

Posted on 1997-09-27
1
3,523 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

820 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