ccplusplus.com
Learn C, C++ Concepts
Thursday, September 1, 2011
time_t example c code
/* * using time_t sample c code */ #include
#include
#define BUF_128 128 int main (void) { time_t currentTime; struct tm *ts; char cBuffer[BUF_128]; /* * Get the current time */ currentTime = time(0); /* * Format and print the time, "ddd yyyy-mm-dd hh:mm:ss zzz" */ ts = localtime(¤tTime); strftime(cBuffer, sizeof(cBuffer), "%a %Y-%m-%d %H:%M:%S %Z", ts); printf("%s\n", cBuffer); return 0; } /* * OUTUT * [sgupta@rhel54x64 time]$ ./time_t Wed 2011-08-31 20:46:46 IST [sgupta@rhel54x64 time]$ */
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment