Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time and date problems 1

Status
Not open for further replies.

killian14

Technical User
Aug 1, 2003
1
US
I am a beginner in C, and am writing a program with a lot of date and date interval calculations. I am separating the dates into day, month, and year variables, but I'm wondering if there's an easier way. Can anyone tell me about the time library, or where I might find information about dates in C?
Thanks!
 
Take a look at the manual pages for time() ctime() asctime() localtime() etc.

I picked up this example with a quick google round asking for 'asctime example' There are loads of other examples about once you get the right keywords.



/*using the asctime function*/
#include <stdio.h>
#include <time.h>
int main()
{
struct tm *ptr;
time_t tm;
tm = time(NULL);
ptr = localtime(&tm);
printf(asctime(ptr));

return 0;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top