淡定从容,宁静致远
全部博文(329)
分类: LINUX
2013-01-27 10:58:42
#include
#include
#define BUFSIZE 128
int main(void)
{
time_t cur;
struct tm *tm;
char buf[BUFSIZE];
cur = time(NULL);
printf("%u\n", (unsigned)cur);
tm = localtime(&cur);
printf("y: %d, m: %d, d: %d, h: %d, m: %d, s: %d\n", tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
printf("%s", asctime(tm));
strftime(buf, BUFSIZE, "%m-%d %H:%M", tm);
printf("%s\n", buf);
return 0;
}