Solved

Retrieving the system time in MFC

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
substring method in java 1 98
only14 challenge 19 69
changeXy challenge 13 67
Remove Password Protection from pdf (with password) using an command line executable 5 30
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

896 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now