You are here:

C++/how to get system date

Advertisement


Question
Hi,

can u teach me the easiest way on how to get the system date? Is there a predefined function to perform this function?

I need the date to calculate the days elapsed to award interest for customers in a bank account system. This is my college assignment. Your help would be greatly appreciated. Thanks.

I am using Dev 4.9.9.2 C++ compiler

Answer
Hello Nick, thank you for the question.

Sure, there is a predefined function to do this for you. It is called time() and is located in <time.h>. It takes a structure called a time_t as a parameter by pointer and fills it out with the system time. It does it kind of weird though, so I suggest you read the MSDN documentation on it, which can be found here:

http://www.cplusplus.com/ref/ctime/localtime.html

There is also a function called localtime() which can convert timezones for you. I hope this answers your question.

I hope this information was helpful.

- Eddie

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.