time_t now = time(NULL);
struct tm *tm;
//struct tm *localtime(const time_t *timep);
tm = localtime(&now);
char buffer[128];
#if 0
struct tm
{
int tm_sec; /* seconds */
int tm_min; /* minutes */
int tm_hour; /* hours */
int tm_mday; /* day of the month */
int tm_mon; /* month */
int tm_year; /* year */
int tm_wday; /* day of the week */
int tm_yday; /* day in the year */
int tm_isdst; /* daylight saving time */
};
#endif
memset(buffer,0, sizeof(buffer));
//int snprintf(char *str, size_t size, const char *format,...);
snprintf(buffer, sizeof(buffer) - 1, "Current time: %04d-%02d-%02d
%02d:%02d:%02d\n", tm->tm_year + 1900, tm->tm_mon, tm->tm_mday, tm->tm_hour,
tm->tm_min, tm->tm_sec);
get local time promming