System Time and Date Help pls

I'm not asking for a lot, I just want to be able to manipulate time and date in program.

for example I want to be able to make statements that say:


1
2
3
4
5
if (date is 15th of a month) 
       {
           cout<<"todays date is"<<date;
       }


that's not the code ofc, but I just want to know what library I need to access that day and how to manipulate it. if you need a better example. let me know I can make one.

Thanks
The library is ctime, specifically time.h - http://www.cplusplus.com/reference/clibrary/ctime/time/

It will give you the time since January 1st 1970. You can divide to get the date. i.e. divide by 3600 to get the time in hours.

Edit: Looks like the localtime function is what you're looking for: http://www.cplusplus.com/reference/clibrary/ctime/localtime/
Last edited on
Topic archived. No new replies allowed.