[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

time in seconds since 1980?

Posted on 1997-11-30
2
Medium Priority
?
1,110 Views
Last Modified: 2008-03-17
I have to write a function which evaluates
from the system time a number of seconds.
This number of seconds must represent the
number of seconds since 1/1/1980 til the mentioned
system time.
The number of seconds should be an integer (or
long integer) value.

I work with Visual C++ (4.0 & 5.0).
Does already such a function exist?

Thanks
Dani
0
Comment
Question by:dgraf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
wpinto earned 200 total points
ID: 1174407
Hi Dani,

There is no simple function which will do the job for you. But the result could be easily achieved using the CTime & CTimeSpan classes of MFC

The following piece of code will give you the required results

  CTime t = CTime::GetCurrentTime();
  CTimeSpan ts = t - CTime(1980, 1, 1);
  long lNoOfSeconds = ts.GetTotalSeconds();

The total no of seconds from 1/1/1980 till the current time is available in the long variable lNoOfSeconds.

Hope this helps

Wilfred
0
 

Author Comment

by:dgraf
ID: 1174408
Excellent, it works perfectly!

Thanks
Dani
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

656 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