Solved

Retrieving the system time in MFC

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 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

21 Experts available now in Live!

Get 1:1 Help Now