Solved

time in seconds since 1980?

Posted on 1997-11-30
2
1,050 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
2 Comments
 
LVL 2

Accepted Solution

by:
wpinto earned 50 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

744 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

10 Experts available now in Live!

Get 1:1 Help Now