cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
time increase
time increase
Jul 27, 2011 at 3:57pm UTC
codrgi
(63)
how would i be able in c++ to increase the time() by a day or month?
Jul 27, 2011 at 4:52pm UTC
shacktar
(1187)
Didn't like my answer?
http://www.cplusplus.com/forum/beginner/47584/
Jul 27, 2011 at 5:05pm UTC
codrgi
(63)
This is for a different function - time(), not systemtime,localtime :)
Jul 27, 2011 at 5:09pm UTC
shacktar
(1187)
The time() function returns the number of seconds since
00:00 hours, Jan 1, 1970 UTC
. See the example here:
http://www.cplusplus.com/reference/clibrary/ctime/time/
To add 1 day, you have to add 86400 (24 hours * 60 minutes/hour * 60 seconds/minute).
To add 1 month, you have to figure out how many days there are in the current month and add that many days (times 86400).
Topic archived. No new replies allowed.