Solved

time in seconds since 1980?

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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
Would like to move button in a function 3 92
Least Squares Curve Fitting 4 133
How can i compile this github project?? 2 102
No module found pypyodbc, 3 54
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

732 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